文章内容
- 一个opencv检测角点的程序
运行效果
cpp
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
void detectCorners(Mat image)
{
Mat grayImage;
cvtColor(image, grayImage, COLOR_BGR2GRAY);
vector<Point2f> corners;
goodFeaturesToTrack(grayImage, corners, 100, 0.01, 10);
for (int i = 0; i < corners.size(); i++)
{
circle(image, corners[i], 5, Scalar(0, 0, 255), -1);
}
imshow("Corner Detection", image);
waitKey(0);
}
int main()
{
Mat image = imread("E:\\SOFT_SL\\Opencv_Check\\biaoding.png");
if (image.empty())
{
cout << "Failed to load image" << endl;
return -1;
}
detectCorners(image);
return 0;
}