Shape module

asked Jun 24 '15

Mimikian gravatar image

updated Jun 24 '15

I am trying to calculate distance between 2 images using shape context method (C++)

my code is:

cv::Ptr <cv::shapecontextdistanceextractor> mysc = cv::createShapeContextDistanceExtractor();
Mat query = imread("images/26.bmp", IMREAD_GRAYSCALE);
vector<point> contQuery = simpleContour(query);
Mat iiIm = imread("images/25.bmp", IMREAD_GRAYSCALE);
vector<point> contii = simpleContour(iiIm);
float distance = mysc->computeDistance(contQuery, contii); 
cout << distance << endl;

But when i add theses lines before the mentioned code:

Mat test = imread("images/8.bmp", IMREAD_GRAYSCALE); 
vector<point> testContour= simpleContour(test);

distance changes and gives new value, So why calling simpleContour() for another image can change the next values. implementation of simpleContour() exists in this file:
https://github.com/Itseez/opencv/blob...

Preview: (hide)

Comments

@Mimikian, did you notice that the simpleContour functions is randomly subsampling a larger contour? In fact, it should change the distance value for every execution of the program. This simple subsampling method should be taken with care for different applications.

juanmanpr gravatar imagejuanmanpr (Jun 28 '15)edit