这些特征在图像缩放、噪声、高亮度等环境下依然能被检测到,这些区域通常在图像中高对比度的地方,例如边;[ 原文:To perform reliable recognition, it is important that the features extracted from the training image be detectable even under changes in image scale, noise and illumination. Such points usually lie on high-contrast regions of the image, such as object edges.]
这些特征的相对位置不会因为在不同的图像中而改变。[原文:Another important characteristic of these features is that the relative positions between them in the original scene shouldn’t change from one image to another. ]
#include<iostream>#include<opencv2\core.hpp>#include<opencv2\highgui.hpp>#include<opencv2\features2d.hpp>#include<opencv2\xfeatures2d.hpp>
using namespace cv;
using namespace cv::xfeatures2d;
using std::cout;
using std::endl;intmain(){
Mat src =imread("1.jpg", IMREAD_GRAYSCALE);if(src.empty()){
cout <<"Could not open or find the image!\n"<< endl;return-1;}//-- Step 1: Detect the keypoints using SURF Detectorint minHessian =400;
Ptr<SURF> detector = SURF::create(minHessian);//SURF//Ptr<SIFT> detector = SIFT::create();//SIFT
std::vector<KeyPoint> keypoints;
detector->detect(src, keypoints);//-- Draw keypoints
Mat img_keypoints;drawKeypoints(src, keypoints, img_keypoints);//-- Show detected (drawn) keypointsimshow("SURF Keypoints", img_keypoints);waitKey();return0;}