Feature Detection is to find some specific points (mostly corner) which can uniquely represent their location in the image. So these points are feature points, and we can describe them using descriptor.

There are several common algorithms in Feature Detection.

Harris Corner Detection help detect corner points in a certain image.

Basic Idea

For each pixel $(x, y)$, it calculates a $2\times2$ gradient covariance matrix $M^{(x,y)}$ over a $blockSize\times blockSize$ neighborhood. Then, it computes the following characteristic:

where

$det(M) = \lambda_1 \lambda_2$

$trace(M) = \lambda_1 + \lambda_2$

$\lambda_1$ and $\lambda_2$ are the eigen values of $M$

So the values of these eigen values decide whether a region is corner, edge or flat.

When $|R|$ is small, which happens when $\lambda_1$ and $\lambda_2$ are small, the region is flat.

When $R<0$, which happens when $\lambda_1>> \lambda_2$ or vice versa, the region is edge.

When $R$ is large, which happens when $\lambda_1$ and $\lambda_2$ are large and $\lambda_1 \sim \lambda_2$, the region is a corner.

OpenCV API

cornerHarris()

Parameters

src Input single-channel 8-bit or floating-point image.