1

I have two images looking alike, that I want to compare with openCV for similarity (percentage or number).

On of them is in a "database" and being compare to a handdrawn version of the shape.

Standardized Image Handdrawn image

This works well with matchShapes() and findContours if the shapes have a closed area, for example a triangle and a handdrawn triangle. Unfortunately it doesnt work at all with the images on top.

Is there any function that can do this?

user1810087
  • 5,146
  • 1
  • 41
  • 76
  • Might be a hack, but what if you "inflate" the shapes, so they're "fatter" for lack of a better term. If you do this to both images, I think the `findContours` will be able to pick up the more solid shapes. – Alexander Kondratskiy Jan 10 '20 at 16:18
  • Does this help? [Algorithm for finding similar images](https://stackoverflow.com/questions/75891/algorithm-for-finding-similar-images) or this: [Handwritten Digits Classification](https://www.learnopencv.com/handwritten-digits-classification-an-opencv-c-python-tutorial) – rustyx Jan 10 '20 at 16:58
  • First of all, which method of findContours are you using? In some edges of images, find contours can find 2 contours in a line: one is in and the other is out. You need to choose best method of findContours and also matchShape. To be sure, you also need to see which contours are being compared by matchShape. To do that u can draw comparing contours on a zero mat image then use imshow to see. Check the contours which is being compared and check the result of matchShape. In my opinion, there can be some missing parts on contours or because of choosing wrong methods of findcontours and matchshape – Yunus Temurlenk Jan 10 '20 at 18:50
  • Can you provide additional examples of shapes please? How many are there in the database? Are the lines always straight? Always horizontal or vertical? You may be able to do something with morphology, e.g. count the line-ends (6 here) and junctions/intersections (2 here). – Mark Setchell Jan 10 '20 at 20:09

0 Answers0