首先放上一张帝国大厦的测试图片。
Harris角点检测框架是使用偏微分来近似平方差的计算,通过计算微分矩阵的两个特征值来决定是否存在角点特征。例如,当两个特征值均较大时,图像块中有角点特征,仅当其中一个特征值角点,则图像块中存在边缘特征。
GoodFeaturesToTrackDetector harris_detector(1000, 0.01, 10, 3, true);
vector<KeyPoint>keypoints;
harris_detector.detect(gray_img, keypoints);
在OpenCV中,使用GoodFeaturesToTrackDetector 定义一个进行1000个角点检测的Harris角点检测器,使用drawKeypoints函数进行角点绘制。
作者在测试时发现以下两种情况均可以在图像中进行角点绘制。
1)drawKeypoints(Mat(), keypoints, img