C++/OpenCV - How can i get my image after using flann::index? (With BoF)
I use BoW with SURF and FlannBasedMatcher for image retrieval inside a database. I extracted all my features of my database (Training) using SURF , then i builded the vocabulary and finally i got the BOF frequency histograms for each pictures inside my database (training).
to be clear, i don't put the details of all of this process but tell me if you need some details.
So at this step i have :
cv::Mat allDescriptors --> descriptors of my all database (training)
cv::Mat Vocabulary --> codebook representation
cv::Mat responseDatabase --> frequency histograms for each pictures inside my database
Then i used a query and compute its reponse according to the vocabulary computed just before. Finally i have this data :
- cv::Mat responseQuery --> frequency histogram of my query
Now i have some difficulties. I used
cv::flann::Index flannIndex(responseDatabase, cv::flann::KDTreeIndexParams(), cvflann::FLANN_DIST_EUCLIDEAN);
cv::Mat results, dists;
int k=2;
flannIndex.knnSearch(responseQuery, results, dists, k, cv::flann::SearchParams() );
It worked well and i got this results :
- cv::Mat results --> [38, 117]
- cv::Mat dist --> [0.0010655867, 0.013091294]
But now with those results, how can i recover the two pictures corresponding to my 2 nearest neighbors ? Indeed, i don't have any trace of the pictures inside each of my data.
Maybe, i missed one step but which one ?
Thank
hmm, if your responseDatabase had 1 row per image/histogram, [38, 117] should be the 2 closest indices from the responseDatabase
Yes i know but the responseDatabase correspond to histograms and not the picture ! I would like to display the picture corresponding to this histogram...Do you know ?
you would have to keep the image list used while acquiring the surf features
Yes this is what i did. Simply. But i don't know if it was the best way. Anyway thank !
@lilouch, discovered any other way to save the flann index scalable, savable and editable to disk?