goodFeaturesToTrack函数中mask的使用

const char *filename = "D:\\vs2015\\KCFcpp-master\\src\\1.jpg";
	Mat src;
	src = imread(filename, 0);

	Rect roi(1024, 400, 256, 130);//感兴趣的框(x,y,w,h)
	Mat mask = Mat::zeros(src.size(), CV_8UC1);//mask初始化全为0
	mask(roi).setTo(255);//将非roi区域置为255

	vector<Point2f> dst;
	goodFeaturesToTrack(src, dst, 500, 0.01, 3,mask, 3, true, 0.04);
	Mat show_dst;
	src.copyTo(show_dst);
	for (int i = 0;i < (int)dst.size();i++)
	{
		circle(show_dst, dst[i], 3, Scalar(255, 255, 255), 2, 8);
	}
	namedWindow("dst");
	imshow("dst", show_dst);
	waitKey(0);
	return 0;

展开阅读全文

没有更多推荐了,返回首页