MCPcopy Create free account
hub / github.com/creatale/node-dv / goodFeaturesToTrack

Method goodFeaturesToTrack

deps/opencv/modules/imgproc/src/featureselect.cpp:55–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
56 int maxCorners, double qualityLevel, double minDistance,
57 InputArray _mask, int blockSize,
58 bool useHarrisDetector, double harrisK )
59{
60 Mat image = _image.getMat(), mask = _mask.getMat();
61
62 CV_Assert( qualityLevel > 0 && minDistance >= 0 && maxCorners >= 0 );
63 CV_Assert( mask.empty() || (mask.type() == CV_8UC1 && mask.size() == image.size()) );
64
65 Mat eig, tmp;
66 if( useHarrisDetector )
67 cornerHarris( image, eig, blockSize, 3, harrisK );
68 else
69 cornerMinEigenVal( image, eig, blockSize, 3 );
70
71 double maxVal = 0;
72 minMaxLoc( eig, 0, &maxVal, 0, 0, mask );
73 threshold( eig, eig, maxVal*qualityLevel, 0, THRESH_TOZERO );
74 dilate( eig, tmp, Mat());
75
76 Size imgsize = image.size();
77
78 vector<const float*> tmpCorners;
79
80 // collect list of pointers to features - put them into temporary image
81 for( int y = 1; y < imgsize.height - 1; y++ )
82 {
83 const float* eig_data = (const float*)eig.ptr(y);
84 const float* tmp_data = (const float*)tmp.ptr(y);
85 const uchar* mask_data = mask.data ? mask.ptr(y) : 0;
86
87 for( int x = 1; x < imgsize.width - 1; x++ )
88 {
89 float val = eig_data[x];
90 if( val != 0 && val == tmp_data[x] && (!mask_data || mask_data[x]) )
91 tmpCorners.push_back(eig_data + x);
92 }
93 }
94
95 sort( tmpCorners, greaterThanPtr<float>() );
96 vector<Point2f> corners;
97 size_t i, j, total = tmpCorners.size(), ncorners = 0;
98
99 if(minDistance >= 1)
100 {
101 // Partition the image into larger grids
102 int w = image.cols;
103 int h = image.rows;
104
105 const int cell_size = cvRound(minDistance);
106 const int grid_width = (w + cell_size - 1) / cell_size;
107 const int grid_height = (h + cell_size - 1) / cell_size;
108
109 std::vector<std::vector<Point2f> > grid(grid_width*grid_height);
110
111 minDistance *= minDistance;
112

Callers

nothing calls this directly

Calls 14

minMaxLocFunction · 0.85
MatClass · 0.85
sortFunction · 0.85
cvRoundFunction · 0.85
fixedTypeMethod · 0.80
maxFunction · 0.50
minFunction · 0.50
getMatMethod · 0.45
emptyMethod · 0.45
typeMethod · 0.45
sizeMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected