How can i get LSH from ORB descriptors?

asked 2015-09-13 04:12:12 -0600

ruboss gravatar image

I will very thank for your comments and answers I am newbie in Opencv

Please, tell me, how can i get list of hashes from matcher?

My code and interesting rows:

//matcher_->getListOfLsh();

//Get list of hashes "qgdlfospahs....

int main(int argc, char** argv)

{
cv::Mat img1 = cv::imread("categories2.jpg", CV_LOAD_IMAGE_GRAYSCALE);//CV_LOAD_IMAGE_GRAYSCALE

cv::Ptr<cv::FeatureDetector> detector = ORB::create();
cv::Ptr<cv::DescriptorExtractor> descriptor = ORB::create();

std::vector<cv::KeyPoint> keypoints1;
detector->detect(img1, keypoints1);
std::cout«"find "«keypoints1.size()«" keypoints in img1"«std::endl;

cv::Mat descriptors1;
descriptor->compute(img1, keypoints1, descriptors1);

cv::Ptr<cv::DescriptorMatcher> matcher_;
matcher_ = new cv::FlannBasedMatcher(new cv::flann::LshIndexParams(5, 24, 2));

matcher_->add(descriptors1); // i think that here matcher generate hash indexes

//matcher_->getListOfLsh(); i need something like this 
//Get list of hashes "qgdlfospahsy24sa6nhss65s7hns7" for ORB descriptors?


cv::waitKey(0);

return 0;
}
edit retag flag offensive close merge delete

Comments

1

are you really interested in matching here ? the FlannBasedMatcher does not offer such functionality (and might be the wrong tool anyway.)

i'd try with a flann::Index instead.. maybe you can retrieve the hashes from LshIndexParams after training

berak gravatar imageberak ( 2015-09-13 04:24:24 -0600 )edit

@berak Thank you! I am newbie in opencv, can you show me a part of code, which can help me to get hashes from LshIndexParams?

ruboss gravatar imageruboss ( 2015-09-13 13:42:09 -0600 )edit

sorry, i was probably wrong. does not seem possible at all. (Index::getAll() only retrieves the params, not the hashtable).

what do you want to do with it ? can't you do your own hashing ?

berak gravatar imageberak ( 2015-09-14 00:38:59 -0600 )edit

@berak i want to save hashes in mysql table. Then i want set index for hashes and use SELECT for search the same descriptors. I can write my own hashes but it will be more difficult, then use almost ready solution. Thank you for help!

ruboss gravatar imageruboss ( 2015-09-14 03:44:09 -0600 )edit

i guess, you 'll have to write your own lsh then, trying to abuse opencv for this does not seem feasible.

berak gravatar imageberak ( 2015-09-14 03:55:15 -0600 )edit

@berak Thank you very much!

ruboss gravatar imageruboss ( 2015-09-14 06:45:40 -0600 )edit
1

you could take a look here: https://github.com/Itseez/opencv/blob...

berak gravatar imageberak ( 2015-09-14 08:18:29 -0600 )edit