Finding cross on the image

I have set of binary images, on which i need to find the cross (examples attached). I use findcontours to extract borders from the binary image. But i can't understand how can i determine is this shape (border) cross or not? Maybe opencv has some built-in methods, which could help to solve this problem. I thought to solve this problem using Machine learning, but i think there is a simpler way to do this. Thanks!

在二进制图像上交叉

在二进制图像上交叉2


Viola-Jones object detection could be a good start. Though the main usage of the algorithm (AFAIK) is face detection, it was actually designed for any object detection, such as your cross.

The algorithm is Machine-Learning based algorithm (so, you will need a set of classified "crosses" and a set of classified "not crosses"), and you will need to identify the significant "features" (patterns) that will help the algorithm recognize crosses.

The algorithm is implemented in OpenCV as cvHaarDetectObjects()


From the original image, lets say you've extracted sets of polygons that could potentially be your cross. Assuming that all of the cross is visible, to the extent that all edges can be distinguished as having a length, you could try the following.

  • Reject all polygons that did not have exactly 12 vertices required to form your polygon.

  • Re-order the vertices such that the shortest edge length is first.

  • Create a best fit perspective transformation that maps your vertices onto a cross of uniform size

  • Examine the residuals generated by using this transformation to project your cross back onto the uniform cross, where the residual for any given point is the distance between the projected point and the corresponding uniform point.

  • If all the residuals are within your defined tolerance, you've found a cross.
  • Note that this works primarily due to the simplicity of the geometric shape you're searching for. Your contours will also need to have noise removed for this to work, eg each line within the cross needs to be converted to a single simple line.


    Depending on your requirements, you could try some local feature detector like SIFT or SURF. Check OpenSURF which is an interesting implementation of the latter.

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

    上一篇: 在另一个表的select语句中替换一行中的多个标记

    下一篇: 在图像上找到交叉点