简体   繁体   English

测量手绘曲线与模板的相似度,惩罚比例/旋转

[英]Measuring similarity of hand-drawn curve to template, penalizing scale/rotation

I have a simple application, which I wish to present a stroke (an arbitrary, but probably quite simple 2D curved path) on the screen to the user, and ask the user to replicate it, again with a single stroke. 我有一个简单的应用程序,我希望在屏幕上向用户显示一个笔划(任意,但可能非常简单的2D弯曲路径),并要求用户再次单击一次来复制它。 I would like to measure the accuracy with which the user replicates the stroke. 我想衡量用户复制笔画的准确性。

My first attempt at replicating this functionality using cv::matchShapes to compare a vector of the source curve points with a vector of the drawn curve correctly scores shape similarity well, but is actually too robust. 我第一次尝试使用cv :: matchShapes复制此功能以将源曲线点的向量与绘制曲线的向量进行比较,从而正确地评估了形状相似度,但是实际上太健壮了。 I want users to copy the stroke in place, not draw it at an arbitrary position/scale on screen. 我希望用户将笔画复制到位,而不是在屏幕上的任意位置/比例上绘制它。

To be clear, 要清楚一点

  1. Drawing the stroke in either direction should be supported (although presumably this can be added even if the underlying algorithm does not support by testing twice.) 应该支持在任一方向上绘制笔划(尽管即使底层算法两次测试都不支持,也可以添加该笔画)。
  2. The metric should NOT be invariant to translation, rotation, scale, that is the user must draw the shape in place. 度量标准不应平移,旋转,缩放不变,即用户必须在适当位置绘制形状。
  3. The stroke may or may not be closed. 行程可能会闭合也可能不会闭合。 We know in advance whether the template is closed. 我们预先知道模板是否关闭。 If the tempate is closed (such as an ellipse) then we would prefer the user to be able to start and end their stroke at any point on the ellipse. 如果温度是封闭的(例如椭圆形),那么我们希望用户能够在椭圆形的任何点处开始和结束笔划。 We can close the drawn curve before testing for similarity if required. 如果需要,我们可以在测试相似性之前关闭绘制的曲线。

I realize this is the opposite of most computer vision, when you're trying to robustly match arbitrary input. 当您尝试稳固地匹配任意输入时,我意识到这与大多数计算机视觉相反。 In this case, I want to score correctness of input to a very precise target. 在这种情况下,我想对一个非常精确的目标输入的正确性进行评分。 Can anybody please suggest a better approach? 有人可以建议一种更好的方法吗? I'm new to computer vision, although experienced in graphics development in general, so apologize if this is trivial. 我是计算机视觉的新手,尽管通常具有图形开发方面的经验,但是如果这很琐碎,请向我道歉。

A good choice is Chamfer matching . 倒角匹配是一个不错的选择。 It is quite robust, but not invariant to transformations, as you require. 它非常健壮,但根据您的需求,它并非不变。 The input is a point set so it doesn't matter if it's a closed curve or not, and the direction of the stroke doesn't matter either. 输入是一个点集,因此它是否是闭合曲线都无关紧要,笔划的方向也无关紧要。

Although it's a very standard method, I didn't find a Wikipedia article; 尽管这是一种非常标准的方法,但是我没有找到Wikipedia的文章。 this is the best source I found, altough it's actually discussing an extended method. 是我发现的最好的资源,尽管它实际上是在讨论扩展方法。

It should be in OpenCV but again I didn't find any documentation, only this sample . 它应该在OpenCV中,但是我再也没有找到任何文档,仅此示例 But in any case if you have an implementation of a distance transform , it's trivial to write yourself. 但是无论如何,如果您实现了距离转换 ,那么编写自己的代码就很简单了。

Here is the original publication, for reference. 是原始出版物,以供参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM