#include #include "opencv2/opencv.hpp" using namespace std; using namespace cv; void corner_harris() { Mat src = imread("../../resources/images/building.jpg", IMREAD_GRAYSCALE); Mat harris; cornerHarris(src, harris, 3, 3, 0.04); Mat harris_norm; normalize(harris, harris_norm, 0, 255, NORM_MINMAX, CV_8U); Mat dst; cvtColor(src, dst, COLOR_GRAY2BGR); for (int j = 1; j < harris.rows - 1; j++) { for (int i = 1; i < harris.cols - 1; i++) { if (harris_norm.at(j, i) > 120) { if (harris.at(j, i) > harris.at(j - 1, i) && harris.at(j, i) > harris.at(j + 1, i) && harris.at(j, i) > harris.at(j, i - 1) && harris.at(j, i) > harris.at(j, i + 1)) { circle(dst, Point(i, j), 5, Scalar(0, 0, 255), 2); } } } } imshow("src", src); imshow("harris_norm", harris_norm); imshow("dst", dst); waitKey(0); destroyAllWindows(); } void corner_fast() { Mat src = imread("../../resources/images/building.jpg", IMREAD_GRAYSCALE); vector keypoints; FAST(src, keypoints, 60, true); Mat dst; cvtColor(src, dst, COLOR_GRAY2BGR); for (KeyPoint kp : keypoints) { Point pt(cvRound(kp.pt.x), cvRound(kp.pt.y)); circle(dst, pt, 5, Scalar(0, 0, 255), 2); } imshow("src", src); imshow("dst", dst); waitKey(0); destroyAllWindows(); } int main() { corner_fast(); }