Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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