#include <iostream>
int maxCorners = 10;
int maxTrackbar = 25;
const char* source_window = "Image";
void goodFeaturesToTrack_Demo( int, void* );
int main( int argc, char** argv )
{
{
cout << "Could not open or find the image!\n" << endl;
cout << "Usage: " << argv[0] << " <Input image>" << endl;
return -1;
}
createTrackbar(
"Max corners:", source_window, &maxCorners, maxTrackbar, goodFeaturesToTrack_Demo );
goodFeaturesToTrack_Demo( 0, 0 );
return(0);
}
void goodFeaturesToTrack_Demo( int, void* )
{
if( maxCorners < 1 ) { maxCorners = 1; }
vector<Point2f> corners;
double qualityLevel = 0.01;
double minDistance = 10;
int blockSize = 3, gradiantSize = 3;
bool useHarrisDetector = false;
double k = 0.04;
corners,
maxCorners,
qualityLevel,
minDistance,
blockSize,
gradiantSize,
useHarrisDetector,
k );
cout<<"** Number of corners detected: "<<corners.size()<<endl;
int r = 4;
for( size_t i = 0; i < corners.size(); i++ )
{
circle( copy, corners[i], r,
Scalar(rng.uniform(0,255), rng.uniform(0,255), rng.uniform(0,255)), -1, 8, 0 ); }
imshow( source_window, copy );
cornerSubPix( src_gray, corners, winSize, zeroZone, criteria );
for( size_t i = 0; i < corners.size(); i++ )
{ cout<<" -- Refined Corner ["<<i<<"] ("<<corners[i].x<<","<<corners[i].y<<")"<<endl; }
}