goodFeaturesToTrack接口使用

Posted cyssmile

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了goodFeaturesToTrack接口使用相关的知识,希望对你有一定的参考价值。

这一节也是shi_tomasi角点检测。
涉及的api:

CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners,
                                     int maxCorners, double qualityLevel, double minDistance,
                                     InputArray mask = noArray(), int blockSize = 3,
                                     bool useHarrisDetector = false, double k = 0.04 );

CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners,
                                     int maxCorners, double qualityLevel, double minDistance,
                                     InputArray mask, int blockSize,
                                     int gradientSize, bool useHarrisDetector = false,
                                     double k = 0.04 );

@param image Input 8-bit or floating-point 32-bit, single-channel image.
@param corners Output vector of detected corners.
@param maxCorners Maximum number of corners to return. If there are more corners than are found,
the strongest of them is returned. `maxCorners <= 0` implies that no limit on the maximum is set
and all detected corners are returned.
@param qualityLevel Parameter characterizing the minimal accepted quality of image corners. The
parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue
(see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the
quality measure less than the product are rejected. For example, if the best corner has the
quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure
less than 15 are rejected.
@param minDistance Minimum possible Euclidean distance between the returned corners.
@param mask Optional region of interest. If the image is not empty (it needs to have the type
CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
@param blockSize Size of an average block for computing a derivative covariation matrix over each
pixel neighborhood. See cornerEigenValsAndVecs .
@param useHarrisDetector Parameter indicating whether to use a Harris detector (see #cornerHarris)
or #cornerMinEigenVal.
@param k Free parameter of the Harris detector.

@sa  cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform,

实验示范

	Mat gray;
	cvtColor(images,gray,COLOR_BGR2GRAY);

	vector<Point2f> corners;
	double quiltyLevel = 0.01;
	goodFeaturesToTrack(gray,corners,3, quiltyLevel,10,Mat(),3,false,0.04);
	RNG rng(12345);
	for (int i = 0; i < corners.size(); i++) {
		int b = rng.uniform(0, 255);
		int g = rng.uniform(0, 255);
		int r = rng.uniform(0, 255);
		circle(images, corners[i], 2, Scalar(b, g, r), 2, 8);
	}

技术图片
技术图片

这种方式处理速度较快,可以用于实时视频中的角点检测。

以上是关于goodFeaturesToTrack接口使用的主要内容,如果未能解决你的问题,请参考以下文章

Android - OpticalFlow:calcOpticalFlowPyrLK & goodFeaturesToTrack 返回相同的点

机器学习进阶-光流估计 1.cv2.goodFeaturesToTrack(找出光流估计所需要的角点) 2.cv2.calcOpticalFlowPyrLK(获得光流检测后的角点位置) 3.cv2.

opencv“向量迭代器不兼容”

物体跟踪没有好的特征点

这段代码在做啥?

使用光流的 OpenCV 跟踪