Feature point detection target
In this tutorial, we will cover:
- Use the Featuredetector interface to discover points of interest. In particular:
- Use Surffeaturedetector and its function detect to implement the detection process
- Use function drawkeypoints to draw detected key points
Theoretical code
The code for this tutorial is shown below. You can also download from this link to the source code
#include <stdio.h>#include <iostream>#include "opencv2/core/core.hpp"#include "opencv2/features2d/features2d.hpp"#include "opencv2/highgui/highgui.hpp"UsingNamespaceCv;voidReadme();/** @function Main */IntMain(Intargc,Char**Argv){If(argc!=3){Readme();Return-1;}MatImg_1=Imread(Argv[1],Cv_load_image_grayscale);MatImg_2=Imread(Argv[2],Cv_load_image_grayscale);If(!Img_1.Data||!Img_2.Data){Std::cout<<" --(!) Error reading Images "<<Std::Endl;Return-1;}--Step 1:detect the keypoints using SURF DetectorIntMinhessian=400;SurffeaturedetectorDetector(Minhessian);Std::Vector<KeyPoint>Keypoints_1,Keypoints_2;Detector.Detect(Img_1,Keypoints_1);Detector.Detect(Img_2,Keypoints_2);--Draw KeypointsMatImg_keypoints_1;MatImg_keypoints_2;Drawkeypoints(Img_1,Keypoints_1,Img_keypoints_1,Scalar::All(-1),Drawmatchesflags::DEFAULT);Drawkeypoints(Img_2,Keypoints_2,Img_keypoints_2,Scalar::All(-1),Drawmatchesflags::DEFAULT);--Show detected (drawn) keypointsImshow("Keypoints 1", img_keypoints_1 ); imshow("Keypoints 2", img_keypoints_2 ); waitkey(0); return 0; } /** @function Readme * /void Readme() { std::cout << "Usa GE:./surf_detector << std::Endl; }< /c13> Interpreting the results
-
This is the feature point detection result of the first graph:
-
Here is the feature point detection for the second image:
Translators
Shuai Zheng, <[email protected], http://www.cbsr.ia.ac.cn/users/szheng/
From:http://www.opencv.org.cn/opencvdoc/2.3.2/html/doc/tutorials/features2d/feature_detection/feature_ Detection.html#feature-detection
OPENCV Feature Point Detection