From b7f2a4da69a83bb9fa944667fc8290deb430a17e Mon Sep 17 00:00:00 2001 From: berak Date: Thu, 5 Mar 2015 10:15:35 +0100 Subject: [PATCH] fix features2d tutorials --- .../feature_flann_matcher.markdown | 18 ++++++------------ .../feature_homography.markdown | 17 +++++------------ 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.markdown b/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.markdown index 0e983d925d..b310c65b9f 100644 --- a/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.markdown +++ b/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.markdown @@ -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 detector = SURF::create(); + detector->setMinHessian(minHessian); std::vector 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 ); diff --git a/doc/tutorials/features2d/feature_homography/feature_homography.markdown b/doc/tutorials/features2d/feature_homography/feature_homography.markdown index dae120b898..98c3374ea2 100644 --- a/doc/tutorials/features2d/feature_homography/feature_homography.markdown +++ b/doc/tutorials/features2d/feature_homography/feature_homography.markdown @@ -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 detector = SURF::create( minHessian ); std::vector 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 );