其他分享
首页 > 其他分享> > SIFT特征点检测实现

SIFT特征点检测实现

作者:互联网

 

 

 

 

 

 

 

 

 

 

 

 检测代码:

 

 1 #include <opencv2/opencv.hpp>
 2 #include <opencv2/xfeatures2d.hpp>
 3 #include <iostream>
 4 
 5 using namespace cv;
 6 using namespace std;
 7 using namespace cv::xfeatures2d;
 8 
 9 int main(int argc, char** argv) {
10     Mat src = imread("L:/4.jpg");
11     if (src.empty()) {
12         printf("could not load image...\n");
13         return -1;
14     }
15     namedWindow("input image", CV_WINDOW_AUTOSIZE);
16     imshow("input image", src);
17 
18     int numFeatures = 400;    //检测400个特征点              
19     Ptr<SIFT> detector = SIFT::create(numFeatures);
20     vector<KeyPoint> keypoints;
21     detector->detect(src, keypoints, Mat());  //开始检测
22     printf("Total KeyPoints : %d\n", keypoints.size());  //打印keypoints的数量信息
23 
24     Mat keypoint_img;
25     drawKeypoints(src, keypoints, keypoint_img, Scalar::all(-1), DrawMatchesFlags::DEFAULT);
26     //将关键点画到图上
27     namedWindow("SIFT KeyPoints", CV_WINDOW_AUTOSIZE);
28     imshow("SIFT KeyPoints", keypoint_img);
29 
30     waitKey(0);
31     return 0;
32 }

 

结果:

 

标签:src,img,特征,检测,image,keypoints,int,SIFT
来源: https://www.cnblogs.com/Jack-Elvis/p/11690105.html