法式:
#include <opencv2\opencv.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\features2d\features2d.hpp>
#include <opencv2\core\core.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat image_color = imread("Lighthouse.jpg", 1);
Mat image_gray;
cvtColor(image_color, image_gray, COLOR_BGR2GRAY);
//设置角点检测参数
vector<Point2f> corners;
int max_corners = 500;
double quality_level = 0.01;
double min_distance = 3.0;
int block_size = 3;
bool use_harris = false;
double k = 0.04;
goodFeaturesToTrack(image_gray,
corners,
max_corners,
quality_level,
min_distance,
Mat(),
block_size,
use_harris,
k);
//将检测到的角点绘制到原图上
for (int i = 0; i < corners.size(); i++)
{
circle(image_color, corners[i], 1, Scalar(0, 0, 255), 2, 8, 0);
}
namedWindow("house corner",CV_WINDOW_NORMAL);
imshow("house corner", image_color);
waitKey(0);
return 0;
}
文章插图
3cornerSubPix()格局
推荐阅读
- OpenCV:相机标定示例程序的使用
- OpenCV:相机标定函数和程序
- AE的动力角点效果怎么制作
- 解决无数人对安装opencv环境变量疑惑的终极答案
- python3+opencv3用拉普拉斯算子实现边缘检测
- python3.6.5环境 opencv3.3.1进行直方图均衡