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.
Asked
Active
Viewed 99 times
1 Answers
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?