Shape module

asked 2015-06-24 17:13:06 -0500

Mimikian gravatar image

updated 2015-06-24 17:50:19 -0500

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:

edit retag flag offensive close merge delete


@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 ( 2015-06-28 13:37:14 -0500 )edit