title: Opencv match contour image
body: <p>I'd like to know what would be the best strategy to compare a group of contours, in fact are edges resulting of a canny edges detection, from two pictures, in order to know which pair is more alike. </p>
  
  <p>I have this image:</p>
  
  <p><a href="http://i55.tinypic.com/10fe1y8.jpg" rel="noreferrer">http://i55.tinypic.com/10fe1y8.jpg</a></p>
  
  <p>And I would like to know how can I calculate which one of these fits best to it:</p>
  
  <p><a href="http://i56.tinypic.com/zmxd13.jpg" rel="noreferrer">http://i56.tinypic.com/zmxd13.jpg</a></p>
  
  <p>(it should be the one on the right)</p>
  
  <p>Is there anyway to compare the contours as a whole? 
  I can easily rotate the images but I don't know what functions to use in order to calculate that the reference image on the right is the best fit.</p>
  
  <p>Here it is what I've already tried using opencv:</p>
  
  <p>matchShapes function - I tried this function using 2 gray scales images and I always get the same result in every comparison image and the value seems wrong as it is 0,0002.</p>
  
  <p>So what I realized about matchShapes, but I'm not sure it's the correct assumption, is that the function works with pairs of contours and not full images. Now this is a problem because although I have the contours of the images I want to compare, they are hundreds and I don't know which ones should be "paired up".</p>
  
  <p>So I also tried to compare all the contours of the first image against the other two with a <em>for</em> iteration but I might be comparing,for example, the contour of the 5 against the circle contour of the two reference images and not the 2 contour.</p>
  
  <p>Also tried simple cv::compare function and matchTemplate, none with success. </p>