Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV || contour similarity

As you can see in the image, I would like to compare these contours.

contours

I need my OpenCV program to return TRUE when of these contours are compared to each other. They all kind off look the same but as you can see they are not exactly the same.

The result you see here is what I have returned from the function findContours.

So I am looking for the right approach for similarity for these contours.

Any help would be amazing.

Thank you very much in advance.

like image 288
Wim Vanhenden Avatar asked Feb 19 '12 22:02

Wim Vanhenden


People also ask

How do you compare two contours in OpenCV?

OpenCV comes with a function cv. matchShapes() which enables us to compare two shapes, or two contours and returns a metric showing the similarity. The lower the result, the better match it is.

What does boundingRect return?

boundingRect() returns the 4 points of the bounding box as shown below. # The first order of the contours. c_0 = contours[0]# Get the 4 points of the bounding rectangle. x, y, w, h = cv2.boundingRect(c_0)# Draw a straight rectangle with the points.

What does Findcontour return?

Since OpenCV 3.2, findContours() no longer modifies the source image but returns a modified image as the first of three return parameters. In OpenCV, finding contours is like finding white object from black background. So remember, object to be found should be white and background should be black.


1 Answers

Take a look at cvMatchShapes() (which used to be call cvMatchContours()).

like image 179
Adi Shavit Avatar answered Sep 27 '22 17:09

Adi Shavit