C++/OpenCV - Why FLANN::index with ORB and LSH works very badly?

asked 2014-08-20 03:01:07 -0600

lilouch gravatar image

I'm looking for a picture inside a database (1000 pictures). In order to do that, i use Bag of Features with ORB. Then, i use LSH.

There is something i don't understand at all. With KD-TREE i got among my 3 nearest neighbor one good match then, the other results are very bad. I think it's because KD-TREE works very badly in highly dimentional data.

Index : [47, 194, 1118] Dist : [0, 0.01984383, 0.021690277]

Then when i use LSH with hamming distance, i always get the same bad results results whatever my query image.

Index : [0, 1, 2] Dist : [0, 0, 0]

 responseDatabase.convertTo(responseDatabase,CV_8U);
 cv::flann::Index flannIndex(responseDatabase,cv::flann::LshIndexParams(20,10,2), cvflann::FLANN_DIST_HAMMING);
cv::Mat results, dists;
 int k=3; // find the 3 nearest neighbors


// search (nearest neighbor)
responseQuery.convertTo(responseQuery,CV_8U);
flannIndex.knnSearch(responseQuery, results, dists, k, cv::flann::SearchParams() );

and

 cv::flann::Index flannIndex(responseDatabase,cv::flann::KDTreeIndexParams,cvflann::FLANN_DIST_EUCLIDEAN);
cv::Mat results, dists;
 int k=3; // find the 3 nearest neighbors


// search (nearest neighbor)
flannIndex.knnSearch(responseQuery, results, dists, k, cv::flann::SearchParams() );

responseQuery --> cv::Mat which contains the response histogram of the query databaseQuery --> cv::Mat which contains the response histogram of all my pictures of my database

Do i miss something ? Maybe with ORB there is something i have to do besides the others things ? I precise that firstly i used SIFT and SURF with LSH and KD-TREE and i got pretty good results even if it was not perfect.

Can anyone explain me why ? I really don't understand why.

However i use BruteForce-Hamming as a matcher.

edit retag flag offensive close merge delete