萌新学习手册:surf特征检测

算法原理:https://www.cnblogs.com/jinjidexuetu/p/90ace4e8de574e3d5f4e6ac16a0dc157.html

#include
using namespace xfeatures2d;

 嗯,在开头要包含这个库然后申明命名空间

src = imread("C:/Users/pbiha/Desktop/image/1.png",IMREAD_GRAYSCALE);

IMREAD_GRAYSCALE就是0,表示读入一张灰度图像

Ptr<>

这是一个智能指针像指针一样的用,但是更加方便内存的管理

#include
#include
#include
using namespace xfeatures2d;
using namespace std;
using namespace cv;


int main() {
	Mat src,result_img;
	src = imread("C:/Users/pbiha/Desktop/image/1.png",IMREAD_GRAYSCALE);
	if (src.empty()) {
		puts("Can't find the img...");
		return -1;
	}
	namedWindow("input", CV_WINDOW_AUTOSIZE);
	imshow("input", src);
	int minHessian = 300;
	Ptrdetector = SURF::create(minHessian);
	vectorketpoints;
	detector->detect(src, ketpoints, Mat());
	drawKeypoints(src, ketpoints, result_img, Scalar::all(-1),DrawMatchesFlags::DEFAULT);
	namedWindow("outputimg", CV_WARP_FILL_OUTLIERS);
	imshow("outputimg", result_img);
	waitKey(0);
	return 0;
}

 

你可能感兴趣的:(计算机视觉)