0

I am trying to code an object recognition program to detect a query image from a set of training images. For this purpose I want to store ALL key descriptors of ALL key points of ALL train images in one giant matrix and pass this matrix as an argument to FLANN matching algorithm. However, the problem here is how to pass a sequence of images from a given directory to FeatureDetect and FeatureDescriptor class objects. According to openCV doc 3.0, detect member function of FeatureDetector class takes in a sequence of images. But how to do it? I am confused pls help.

Screen shot OpenCV Doc FeatureDetector Class

Vino
  • 167
  • 2
  • 14
  • just concatenate the results of each single detection/description. However, detector results (pixel locations) are useless to remember if you mix images, aren't they? – Micka Mar 05 '16 at 11:25

1 Answers1

0

If I understand correctly your question is about loading the images you need to pass to the FeatureDetector.

I suggest to list the files in the folder using: How can I get the list of files in a directory using C or C++?.

Then on each file (probably you need to filters for particular extensions) you can:

vector< string > fileNames;
// uses readdir to fill  fileNames
[...]

// load the images
vector< Mat > images;
for ( size_t i=0; i<fileNames.size(); i++ ) {
   Mat img = imread( fileNames[i] );
   if ( img ) // only valid images
      images.push_back( img );
}

// pass the images to detector

At the end of the cycle you will have the images to pass as first argument for FeatureDetector::detect.

Aren't you worried for the memory needed?

Community
  • 1
  • 1
Matteo
  • 482
  • 3
  • 11