#include<iostream>
#include<opencv2/opencv.hpp>
#include<vector>
using namespace cv;
using namespace std;
int main()
{
Mat srcImage = imread("building.jpg");
imshow("【原图】", srcImage);
//因为强角点检测函数的输入图像是一个单通道的图像,所以,先对原图像进行图像空间的转换
Mat grayImage;
cvtColor(srcImage, grayImage, CV_BGR2GRAY);
//开始进行强角点检测
//先配置需要的函数参数
vector<Point2f> dstPoint2f;
goodFeaturesToTrack(grayImage, dstPoint2f, 200, 0.01, 10, Mat(), 3);
//遍历每个点,进行绘制,便于显示
Mat dstImage;
srcImage.copyTo(dstImage);
for (int i = 0; i < (int)dstPoint2f.size(); i++)
{
circle(dstImage, dstPoint2f[i], 3, Scalar(theRNG().uniform(0, 255), theRNG().uniform(0, 255), theRNG().uniform(0, 255))
, 2, 8);
}
imshow("【检测到的角点图】", dstImage);
//利用goodFeaturesToTrack函数得到的角点向量,进行亚像素角点的检测
TermCriteria criteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 40, 0.001);
cornerSubPix(grayImage, dstPoint2f, S
opencv3 寻找亚像素角点-cornerSubPix函数
最新推荐文章于 2024-04-25 09:19:25 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)