opencv3中SURF特征点检测-两幅图像进行比较

来源:互联网 发布:袁姗姗知乎 编辑:程序博客网 时间:2024/05/22 15:53
#include<iostream>#include<opencv2/opencv.hpp>#include<vector>using namespace cv;using namespace std;int main(){Mat srcImage1 = imread("mofang1.jpg");imshow("【原图】", srcImage1);Mat srcImage2 = imread("mofang2.jpg");imshow("【原图】", srcImage2);//首先得到特征点的集合//先配置参数vector<KeyPoint> keyPoint1;vector<KeyPoint> keyPoint2;//在库中:typedef SURF SurfFeatureDetector;   typedef SURF SurfDescriptorExtractor;所以三者是等价的(别名)SURF surf(1000);//1000为检测算子的阀值surf.detect(srcImage1, keyPoint1, Mat());surf.detect(srcImage2, keyPoint2, Mat());//开始绘制特征点Mat dstImage1;Mat dstImage2;dstImage1.create(srcImage1.size(), srcImage1.type());dstImage2.create(srcImage2.size(), srcImage2.type());drawKeypoints(srcImage1, keyPoint1, dstImage1, Scalar(theRNG().uniform(0, 255), theRNG().uniform(0, 255), theRNG().uniform(0, 255)), 2);drawKeypoints(srcImage2, keyPoint2, dstImage2, Scalar(theRNG().uniform(0, 255), theRNG().uniform(0, 255), theRNG().uniform(0, 255)), 2);imshow("【第一副检测到特征点后的图像】", dstImage1);imshow("【第二幅检测到特征点后的图像】", dstImage2);waitKey(0);return 0;}

0 0
原创粉丝点击