From b8de81749c3071b98174e24b0a5df950f1140cc9 Mon Sep 17 00:00:00 2001 From: moodoki Date: Thu, 14 Nov 2013 00:22:20 +0800 Subject: [PATCH] Slight modification to example code for FLANN matcher with comment on #3344 --- .../feature_flann_matcher/feature_flann_matcher.rst | 6 ++++-- samples/cpp/tutorial_code/features2D/SURF_FlannMatcher.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.rst b/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.rst index 3bf757fc00..153fca2e71 100644 --- a/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.rst +++ b/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.rst @@ -81,12 +81,14 @@ This tutorial code's is shown lines below. You can also download it from `here < printf("-- Max dist : %f \n", max_dist ); printf("-- Min dist : %f \n", min_dist ); - //-- Draw only "good" matches (i.e. whose distance is less than 2*min_dist ) + //-- Draw only "good" matches (i.e. whose distance is less than 2*min_dist, + //-- or a small arbitary value ( 0.02 ) in the event that min_dist is very + //-- small) //-- PS.- radiusMatch can also be used here. std::vector< DMatch > good_matches; for( int i = 0; i < descriptors_1.rows; i++ ) - { if( matches[i].distance <= 2*min_dist ) + { if( matches[i].distance <= max(2*min_dist, 0.02) ) { good_matches.push_back( matches[i]); } } diff --git a/samples/cpp/tutorial_code/features2D/SURF_FlannMatcher.cpp b/samples/cpp/tutorial_code/features2D/SURF_FlannMatcher.cpp index ead7fd7182..09346309ec 100644 --- a/samples/cpp/tutorial_code/features2D/SURF_FlannMatcher.cpp +++ b/samples/cpp/tutorial_code/features2D/SURF_FlannMatcher.cpp @@ -65,12 +65,14 @@ int main( int argc, char** argv ) printf("-- Max dist : %f \n", max_dist ); printf("-- Min dist : %f \n", min_dist ); - //-- Draw only "good" matches (i.e. whose distance is less than 2*min_dist ) + //-- Draw only "good" matches (i.e. whose distance is less than 2*min_dist, + //-- or a small arbitary value ( 0.02 ) in the event that min_dist is very + //-- small) //-- PS.- radiusMatch can also be used here. std::vector< DMatch > good_matches; for( int i = 0; i < descriptors_1.rows; i++ ) - { if( matches[i].distance <= 2*min_dist ) + { if( matches[i].distance <= max(2*min_dist, 0.02) ) { good_matches.push_back( matches[i]); } }