The basic OpenCV function that is used to detect Harris corners is called cv::cornerHarris and is straightforward to use:
- You call it on an input image, and the result is an image of floats saved on cornerStrength that gives you the corner strength at each pixel location, with the following code:
// Detect Harris Corners cv::Mat cornerStrength; cv::cornerHarris(image, // input image cornerStrength, // image of cornerness 3, // neighborhood size 3, // aperture size 0.01); // Harris parameter
- A threshold is then applied to this output image in order to obtain a set of detected corners. This is accomplished with the following code:
// threshold the corner strengths cv::Mat harrisCorners; double threshold= 0.0001; cv::threshold(cornerStrength,harrisCorners, ...