Search code examples
javac++image-processingopencvjavacv

What is CvMatchShapes returning?


I have these two images.

small size

And... larger size

I made them into graysclae images and then passed the two images to cvMatchImageslike so

Double someValue = cvMatchShapes(grayImage, grayImage2, CV_CONTOURS_MATCH_I2, 0);
    System.out.println(someValue);

The value that was printed by sysout was 1.465496453484283. What is this value representing? How can i use it to match other images and also how can I reject those that do not?


Solution

  • the value means how different the two objects are,it represents the Hu moment feature distance between the two shapes. the smaller it is ,more similar the two objects are. A threshold can be used to perform the match like this: if output value is smaller than the threshold, two objects match, or the two objects differ. As to how to choose a threshold, it depends . you can use some instances to train the threshold. I strongly advise you to normalize objects in images to similar size.this will give you better accuracy