Commit 89935fc5 authored by Maria Dimashova's avatar Maria Dimashova

fixed FernDescriptorMatch; optimized keypoint regions matching in…

fixed FernDescriptorMatch; optimized keypoint regions matching in detector/descriptor evaluation; added CalonderDescriptorExtractor to evaluation tests
parent 51822f20
...@@ -2128,7 +2128,8 @@ protected: ...@@ -2128,7 +2128,8 @@ protected:
Params params; Params params;
}; };
CV_EXPORTS Ptr<GenericDescriptorMatch> createGenericDescriptorMatch( const string& genericDescritptorMatchType, const string &paramsFilename = string () ); CV_EXPORTS Ptr<GenericDescriptorMatch> createGenericDescriptorMatcher( const string& genericDescritptorMatcherType,
const string &paramsFilename = string () );
/****************************************************************************************\ /****************************************************************************************\
* VectorDescriptorMatch * * VectorDescriptorMatch *
......
This diff is collapsed.
...@@ -569,7 +569,7 @@ void FernDescriptorMatch::trainFernClassifier() ...@@ -569,7 +569,7 @@ void FernDescriptorMatch::trainFernClassifier()
{ {
assert( params.filename.empty() ); assert( params.filename.empty() );
vector<vector<Point2f> > points; vector<vector<Point2f> > points(collection.images.size());
for( size_t imgIdx = 0; imgIdx < collection.images.size(); imgIdx++ ) for( size_t imgIdx = 0; imgIdx < collection.images.size(); imgIdx++ )
KeyPoint::convert( collection.points[imgIdx], points[imgIdx] ); KeyPoint::convert( collection.points[imgIdx], points[imgIdx] );
...@@ -757,34 +757,34 @@ void VectorDescriptorMatch::write (FileStorage& fs) const ...@@ -757,34 +757,34 @@ void VectorDescriptorMatch::write (FileStorage& fs) const
/****************************************************************************************\ /****************************************************************************************\
* Factory function for GenericDescriptorMatch creating * * Factory function for GenericDescriptorMatch creating *
\****************************************************************************************/ \****************************************************************************************/
Ptr<GenericDescriptorMatch> createGenericDescriptorMatch( const string& genericDescritptorMatchType, Ptr<GenericDescriptorMatch> createGenericDescriptorMatcher( const string& genericDescritptorMatcherType,
const string &paramsFilename ) const string &paramsFilename )
{ {
GenericDescriptorMatch *descriptorMatch = 0; GenericDescriptorMatch *descriptorMatcher = 0;
if( ! genericDescritptorMatchType.compare("ONEWAY") ) if( ! genericDescritptorMatcherType.compare("ONEWAY") )
{ {
descriptorMatch = new OneWayDescriptorMatch(); descriptorMatcher = new OneWayDescriptorMatch();
} }
else if( ! genericDescritptorMatchType.compare("FERN") ) else if( ! genericDescritptorMatcherType.compare("FERN") )
{ {
descriptorMatch = new FernDescriptorMatch(); descriptorMatcher = new FernDescriptorMatch();
} }
else if( ! genericDescritptorMatchType.compare ("CALONDER") ) else if( ! genericDescritptorMatcherType.compare ("CALONDER") )
{ {
//descriptorMatch = new CalonderDescriptorMatch (); //descriptorMatch = new CalonderDescriptorMatch ();
} }
if( !paramsFilename.empty() && descriptorMatch != 0 ) if( !paramsFilename.empty() && descriptorMatcher != 0 )
{ {
FileStorage fs = FileStorage( paramsFilename, FileStorage::READ ); FileStorage fs = FileStorage( paramsFilename, FileStorage::READ );
if( fs.isOpened() ) if( fs.isOpened() )
{ {
descriptorMatch->read( fs.root() ); descriptorMatcher->read( fs.root() );
fs.release(); fs.release();
} }
} }
return descriptorMatch; return descriptorMatcher;
} }
} }
...@@ -24,8 +24,8 @@ int main(int argc, char** argv) ...@@ -24,8 +24,8 @@ int main(int argc, char** argv)
std::string alg_name = std::string(argv[3]); std::string alg_name = std::string(argv[3]);
std::string params_filename = std::string(argv[4]); std::string params_filename = std::string(argv[4]);
GenericDescriptorMatch *descriptorMatch = createGenericDescriptorMatch(alg_name, params_filename); GenericDescriptorMatch *descriptorMatcher = createGenericDescriptorMatcher(alg_name, params_filename);
if( descriptorMatch == 0 ) if( descriptorMatcher == 0 )
{ {
printf ("Cannot create descriptor\n"); printf ("Cannot create descriptor\n");
return 0; return 0;
...@@ -50,10 +50,10 @@ int main(int argc, char** argv) ...@@ -50,10 +50,10 @@ int main(int argc, char** argv)
printf("Finding nearest neighbors... \n"); printf("Finding nearest neighbors... \n");
// find NN for each of keypoints2 in keypoints1 // find NN for each of keypoints2 in keypoints1
descriptorMatch->add( img1, keypoints1 ); descriptorMatcher->add( img1, keypoints1 );
vector<int> matches2to1; vector<int> matches2to1;
matches2to1.resize(keypoints2.size()); matches2to1.resize(keypoints2.size());
descriptorMatch->match( img2, keypoints2, matches2to1 ); descriptorMatcher->match( img2, keypoints2, matches2to1 );
printf("Done\n"); printf("Done\n");
IplImage* img_corr = DrawCorrespondences(img1, keypoints1, img2, keypoints2, matches2to1); IplImage* img_corr = DrawCorrespondences(img1, keypoints1, img2, keypoints2, matches2to1);
...@@ -65,7 +65,7 @@ int main(int argc, char** argv) ...@@ -65,7 +65,7 @@ int main(int argc, char** argv)
cvReleaseImage(&img1); cvReleaseImage(&img1);
cvReleaseImage(&img2); cvReleaseImage(&img2);
cvReleaseImage(&img_corr); cvReleaseImage(&img_corr);
delete descriptorMatch; delete descriptorMatcher;
} }
IplImage* DrawCorrespondences(IplImage* img1, const vector<KeyPoint>& features1, IplImage* img2, IplImage* DrawCorrespondences(IplImage* img1, const vector<KeyPoint>& features1, IplImage* img2,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment