#include<iostream>
#include<opencv2/opencv.hpp>
#include<vector>
using namespace cv;
using namespace std;
int g_nMinDistance = 10;
int g_nMaxValue = 200;
Mat grayImage;
Mat srcImage;
void on_Track(int, void*)
{
if (g_nMaxValue <= 1)
g_nMaxValue = 1;
//开始进行强角点检测
//先配置需要的函数参数
vector<Point2f> dstPoint2f;
goodFeaturesToTrack(grayImage, dstPoint2f, g_nMaxValue, 0.01, g_nMinDistance, 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, Size(3, 3), Size(-1, -1), criteria)