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

#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;
}

猜你喜欢

转载自blog.csdn.net/qq_23880193/article/details/49970489