您的位置:首页 > 运维架构

opencv3 确定图像强角点-goodFeaturesToTrack函数

2015-11-05 23:11 309 查看
#include<iostream>
#include<opencv2/opencv.hpp>
#include<vector>

using namespace cv;
using namespace std;

int main()
{
Mat srcImage = imread("2.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);

waitKey(0);

return 0;
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: