Matching a curve pattern to the edges of an image

I have a target image to be searched for a curve along its edges and a template image that contains the curve. What I need to achieve is to find the best match of the curve in the template image within the target image, and based on the score, to find out whether there is a match or not. That also includes rotation and resizing of the curve. The target image can be the output of a Canny Edge detector if that makes things easier.

I am considering to use OpenCV (by using Python or Processing/Java or if those have limited access to the required functions then by using C) to make things practical and efficient, however could not find out if I can use any functions (or a combination of them) in OpenCV that are useable for doing this job. I have been reading through the OpenCV documentation and thought at first that Contours could do this job, however all the examples show closed shapes as opposed to my case where I need to match a open curve to a part of an edge.

So is there a way to do this either by using OpenCV or with any known code or algorithm that you would suggest?

Here are some images to illustrate the problem:

输入要搜索模板曲线并与其边缘匹配的图像;这也可以是边缘图像,Canny边缘检测器的输出而不是未处理的输入图像

结果匹配 - 包括旋转和调整大小


My first thought was Generalized Hough Transform. However I don't know any good implementation for that.

I would try SIFT or SURF first on the canny edge image. It usually is used to find 2d areas, not 1d contours, but if you take the minimum bounding box around your contour and use that as the search pattern, it should work.

OpenCV has an implementation for that: Features2D + Homography to find a known object

A problem may be getting a good edge image, those black shapes in the back could be distracting.

Also see this Stackoverflow answer: Image Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition

链接地址: http://www.djcxy.com/p/79588.html

上一篇: OpenCV检测角落

下一篇: 将曲线图案匹配到图像的边缘