Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to build an index of a database for image retrieval ?

I would like to use BoW with FLANN in order to index all my pictures inside my database.(For a CBIR project)

What i did :

  1. Loop over all ma database in order to compute the descriptors of each pictures.
  2. Clustering descriptors using K-MEAN
  3. Extraction of BoWDescriptors (Visual words) in order to have a big histogram with all my features
  4. Use FLANN Index to compute an index in each pictures

Code:

// Create Flann LSH index
cv::flann::Index flannIndex(this->descDescriptorbow, cv::flann::LshIndexParams(12, 20, 2), cvflann::FLANN_DIST_HAMMING);

cv::Mat results, dists;

int k=2; // find the 2 nearest neighbors

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

DescriptorBow contains all my BoWfeatures of my database. ResponseHist constains all my BoWfeatures of my folder which contains the test database (Some pictures to evaluate in order to find the nearest neighbor).

but i got an error

OpenCV Error: Bad argument (Only continuous arrays are supported) in buildIndex_, file /home/samoun/Bureau/opencv-2.4.6.1/modules/flann/src/miniflann.cpp, line 317 terminate called after throwing an instance of 'cv::Exception' what(): /home//opencv-2.4.6.1/modules/flann/src/miniflann.cpp:317: error: (-5) Only continuous arrays are supported in function buildIndex_

In order to see the structure of my cv::Mat descDescriptorbow i used

    ofstream compute_info("info.txt", ios::out | ios::trunc);
//responseVector = responseHist.reshape(0,1);
 compute_info << descDescriptorbow << std::endl;
 compute_info.close();

Indeed in my file.txt which contains the boWFeatures,it's not a continious array.

So i don't know if if did well or i missed a step ?

Maybe do you know a tutorial step-by-step because i'm a bit lost ?

Can someone help me ?

click to hide/show revision 2
retagged

updated 2015-12-21 06:33:54 -0600

berak gravatar image

How to build an index of a database for image retrieval ?

I would like to use BoW with FLANN in order to index all my pictures inside my database.(For a CBIR project)

What i did :

  1. Loop over all ma database in order to compute the descriptors of each pictures.
  2. Clustering descriptors using K-MEAN
  3. Extraction of BoWDescriptors (Visual words) in order to have a big histogram with all my features
  4. Use FLANN Index to compute an index in each pictures

Code:

// Create Flann LSH index
cv::flann::Index flannIndex(this->descDescriptorbow, cv::flann::LshIndexParams(12, 20, 2), cvflann::FLANN_DIST_HAMMING);

cv::Mat results, dists;

int k=2; // find the 2 nearest neighbors

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

DescriptorBow contains all my BoWfeatures of my database. ResponseHist constains all my BoWfeatures of my folder which contains the test database (Some pictures to evaluate in order to find the nearest neighbor).

but i got an error

OpenCV Error: Bad argument (Only continuous arrays are supported) in buildIndex_, file /home/samoun/Bureau/opencv-2.4.6.1/modules/flann/src/miniflann.cpp, line 317 terminate called after throwing an instance of 'cv::Exception' what(): /home//opencv-2.4.6.1/modules/flann/src/miniflann.cpp:317: error: (-5) Only continuous arrays are supported in function buildIndex_

In order to see the structure of my cv::Mat descDescriptorbow i used

    ofstream compute_info("info.txt", ios::out | ios::trunc);
//responseVector = responseHist.reshape(0,1);
 compute_info << descDescriptorbow << std::endl;
 compute_info.close();

Indeed in my file.txt which contains the boWFeatures,it's not a continious array.

So i don't know if if did well or i missed a step ?

Maybe do you know a tutorial step-by-step because i'm a bit lost ?

Can someone help me ?