9 In this tutorial you will learn how to:
11 .. container:: enumeratevisibleitemswithsquare
13 * Use the :feature_detector:`FeatureDetector<>` interface in order to find interest points. Specifically:
15 * Use the :surf_feature_detector:`SurfFeatureDetector<>` and its function :feature_detector_detect:`detect<>` to perform the detection process
16 * Use the function :draw_keypoints:`drawKeypoints<>` to draw the detected keypoints
25 This tutorial code's is shown lines below. You can also download it from `here <http://code.opencv.org/projects/opencv/repository/revisions/master/raw/samples/cpp/tutorial_code/features2D/SURF_detector.cpp>`_
31 #include "opencv2/core/core.hpp"
32 #include "opencv2/features2d/features2d.hpp"
33 #include "opencv2/highgui/highgui.hpp"
40 int main( int argc, char** argv )
43 { readme(); return -1; }
45 Mat img_1 = imread( argv[1], CV_LOAD_IMAGE_GRAYSCALE );
46 Mat img_2 = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE );
48 if( !img_1.data || !img_2.data )
49 { std::cout<< " --(!) Error reading images " << std::endl; return -1; }
51 //-- Step 1: Detect the keypoints using SURF Detector
54 SurfFeatureDetector detector( minHessian );
56 std::vector<KeyPoint> keypoints_1, keypoints_2;
58 detector.detect( img_1, keypoints_1 );
59 detector.detect( img_2, keypoints_2 );
62 Mat img_keypoints_1; Mat img_keypoints_2;
64 drawKeypoints( img_1, keypoints_1, img_keypoints_1, Scalar::all(-1), DrawMatchesFlags::DEFAULT );
65 drawKeypoints( img_2, keypoints_2, img_keypoints_2, Scalar::all(-1), DrawMatchesFlags::DEFAULT );
67 //-- Show detected (drawn) keypoints
68 imshow("Keypoints 1", img_keypoints_1 );
69 imshow("Keypoints 2", img_keypoints_2 );
76 /** @function readme */
78 { std::cout << " Usage: ./SURF_detector <img1> <img2>" << std::endl; }
86 #. Here is the result of the feature detection applied to the first image:
88 .. image:: images/Feature_Detection_Result_a.jpg
92 #. And here is the result for the second image:
94 .. image:: images/Feature_Detection_Result_b.jpg