OpenCV学习 角点检测

Harris角点检测

https://www.cnblogs.com/Jack-Elvis/p/11640931.html

https://www.cnblogs.com/jiahenhe2/p/7930802.html

数学推导:
http://www.360doc.com/content/19/1026/20/32196507_869233708.shtml

CV_EXPORTS_W void cornerHarris( InputArray src, OutputArray dst, int blockSize,
                                int ksize, double k,
                                int borderType = BORDER_DEFAULT );

@brief Harris corner detector.

The function runs the Harris corner detector on the image.
For every pixel \((x, y)\) , it calculates a \(2\times2\) gradient covariance matrix \(M^{(x,y)}\) over a \(\texttt{blockSize} \times \texttt{blockSize}\) neighborhood.

\[M = \begin{bmatrix} \sum _{S(p)}(dI/dx)^2 & \sum _{S(p)}dI/dx dI/dy \\ \sum _{S(p)}dI/dx dI/dy & \sum _{S(p)}(dI/dy)^2 \end{bmatrix} \]

where the derivatives are computed using the Sobel operator. 这里面的梯度是通过Sobel算子计算的
主要就是这个M,根据M计算特征值 \(\lambda_1\)\(\lambda_2\)

Then, it computes the following characteristic:

\[\texttt{dst} (x,y) = \mathrm{det} M^{(x,y)} - k \cdot \left ( \mathrm{tr} M^{(x,y)} \right )^2 \]

Corners in the image can be found as the local maxima of this response map.

@param src Input single-channel 8-bit or floating-point image.
@param dst Image to store the Harris detector responses. It has the type CV_32FC1 and the same
size as src .
@param blockSize Neighborhood size (see the details on #cornerEigenValsAndVecs ).
@param ksize Aperture parameter for the Sobel operator.
@param k Harris detector free parameter. See the formula above.
@param borderType Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported.

Shi-Tomasi角点检测

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 );

The function can be used to initialize a point-based tracker of an object.

@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. 质量级别,例如,如果最佳角点的质量度量值为1500,而qualityLevel为0.01,则质量度量值小于15的所有角点都将被拒绝。
@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.

posted @ 2020-06-24 10:42  xyfun72  阅读(153)  评论(0编辑  收藏  举报