fix features2d tutorials
authorberak <px1704@web.de>
Thu, 5 Mar 2015 09:15:35 +0000 (10:15 +0100)
committerberak <px1704@web.de>
Thu, 5 Mar 2015 09:26:45 +0000 (10:26 +0100)
doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.markdown
doc/tutorials/features2d/feature_homography/feature_homography.markdown

index 0e983d9..b310c65 100644 (file)
@@ -54,25 +54,19 @@ int main( int argc, char** argv )
   if( !img_1.data || !img_2.data )
   { std::cout<< " --(!) Error reading images " << std::endl; return -1; }
 
-  //-- Step 1: Detect the keypoints using SURF Detector
+  //-- Step 1: Detect the keypoints using SURF Detector, compute the descriptors
   int minHessian = 400;
 
-  SurfFeatureDetector detector( minHessian );
+  Ptr<SURF> detector = SURF::create();
+  detector->setMinHessian(minHessian);
 
   std::vector<KeyPoint> keypoints_1, keypoints_2;
-
-  detector.detect( img_1, keypoints_1 );
-  detector.detect( img_2, keypoints_2 );
-
-  //-- Step 2: Calculate descriptors (feature vectors)
-  SurfDescriptorExtractor extractor;
-
   Mat descriptors_1, descriptors_2;
 
-  extractor.compute( img_1, keypoints_1, descriptors_1 );
-  extractor.compute( img_2, keypoints_2, descriptors_2 );
+  detector->detectAndCompute( img_1, keypoints_1, descriptors_1 );
+  detector->detectAndCompute( img_2, keypoints_2, descriptors_2 );
 
-  //-- Step 3: Matching descriptor vectors using FLANN matcher
+  //-- Step 2: Matching descriptor vectors using FLANN matcher
   FlannBasedMatcher matcher;
   std::vector< DMatch > matches;
   matcher.match( descriptors_1, descriptors_2, matches );
index dae120b..98c3374 100644 (file)
@@ -42,25 +42,18 @@ int main( int argc, char** argv )
   if( !img_object.data || !img_scene.data )
   { std::cout<< " --(!) Error reading images " << std::endl; return -1; }
 
-  //-- Step 1: Detect the keypoints using SURF Detector
+  //-- Step 1: Detect the keypoints and extract descriptors using SURF
   int minHessian = 400;
 
-  SurfFeatureDetector detector( minHessian );
+  Ptr<SURF> detector = SURF::create( minHessian );
 
   std::vector<KeyPoint> keypoints_object, keypoints_scene;
-
-  detector.detect( img_object, keypoints_object );
-  detector.detect( img_scene, keypoints_scene );
-
-  //-- Step 2: Calculate descriptors (feature vectors)
-  SurfDescriptorExtractor extractor;
-
   Mat descriptors_object, descriptors_scene;
 
-  extractor.compute( img_object, keypoints_object, descriptors_object );
-  extractor.compute( img_scene, keypoints_scene, descriptors_scene );
+  detector->detectAndCompute( img_object, keypoints_object, descriptors_object );
+  detector->detectAndCompute( img_scene, keypoints_scene, descriptors_scene );
 
-  //-- Step 3: Matching descriptor vectors using FLANN matcher
+  //-- Step 2: Matching descriptor vectors using FLANN matcher
   FlannBasedMatcher matcher;
   std::vector< DMatch > matches;
   matcher.match( descriptors_object, descriptors_scene, matches );