Contour compare using OpenCV(source code), cvFindContours, cvMatchShapes

There is shape match function in the OpenCV.
The function name is cvMatchShapes.
This function compares two contours.
If two contours is same, the function returns 0.
conversely, the value of return is larger, more shape different.
So, we use threshold to decide these pair is similar or not.


code start

code end

#findcontour, #contour, #compare

source coude


  1. Anonymous30/5/13 01:35

    you have to free storage like that


  2. Good point, thank you very much.

  3. This is really helpful. What if the size of the contour is smaller or larger than the template contour but the shape is the same? Do you any idea how it will be the same(0)?

  4. I will check the question, and upload the solution soon.
    Thank you.

  5. is there some answer for the above question.
    I am using the above method to find the difference in a character image.
    so if the font is bigger, how can we handle this.
    Please let me know if you find some answers.
    Thanks in advance

    1. I am interesting in your source code, but can not download them. Can you help me?

  6. Today, I was just browsing along and came upon your blog. Just wanted to say good blog and this article helped me a lot, due to which I have found exactly I was looking. Car Insurance Comparison Website