goodFeaturesToTrack函数
1、goodFeaturetoTrack函數
函數作用:
確定圖像的強角點
 
2、goodFeaturetoTrack函數的調用形式
C++:?void?goodFeaturesToTrack(InputArray?image, OutputArray?corners, int?maxCorners, double?qualityLevel, double?minDistance, InputArray?mask=noArray(), int?blockSize=3, bool?useHarrisDetector=false, double?k=0.04?)
 
 
參數詳解:
InputArray?image:輸入圖像。單通道圖像,就是一般是灰度圖像
 
OutputArray?corners:輸出的強角點的坐標屬于vector<point2f> corners
 
int?maxCorners:表示角點的最大數
 
double?qualityLevel:最大最小特征值的乘法因子。定義可接受圖像角點的最小質量因子。
 
double?minDistance:限制因子。得到的角點的最小距離。使用 Euclidian 距離
 
InputArray?mask=noArray():ROI:感興趣區域。函數在ROI中計算角點,如果 mask 為 NULL,則選擇整個圖像。 必須為單通道的灰度圖,大小與輸入圖像相同。mask對應的點不為0,表示計算該點。
 
 
int?blockSize=3:計算某一像素點的協方差的鄰域大小,3,5,7,9,。。。。。。
 
covariation matrix of derivatives over the neighborhood as:
bool?useHarrisDetector=false:計算角點響應時,是不是用HarrisDetector方法進行角點檢測,一般選擇默認false
 
?double?k=0.04 :HarrisDetector檢測角點時所用的參數
 
 
opencv代碼:
#include<opencv2/imgproc/imgproc.hpp> #include<opencv2/core/core.hpp> #include<opencv2/highgui/highgui.hpp> #include<iostream> using namespace cv; using namespace std;int main() {Mat src,src_gray;src= imread("D:6.jpg");cvtColor(src, src_gray, CV_RGB2GRAY);vector<Point2f> corners;double qualityLevel = 0.01;double minDistance = 10;int blockSize = 3;bool useHarrisDetector = false;double k = 0.04; //<span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; line-height: 18px; background-color: rgb(248, 248, 248);">這里是0.04*max(min(e1,e2)),e1,e2是harris矩陣的特征值</span><span style="margin: 0px; padding: 0px; border: none; font-family: Consolas, 'Courier New', Courier, mono, serif; line-height: 18px; background-color: rgb(248, 248, 248);">?</span>int maxCorners = 50;/// Copy the source image goodFeaturesToTrack(src_gray,corners,maxCorners,qualityLevel,minDistance,Mat(),blockSize,useHarrisDetector,k);/// Draw corners detected for (int i = 0; i < corners.size(); i++){/*circle(src, corners[i], 5, Scalar(255), 2, 8, 0);*/circle(src, corners[i], 4, Scalar(0, 255, 0), 2, 8, 0);}imshow("shiyan", src);waitKey(0);return 0; }
總結
以上是生活随笔為你收集整理的goodFeaturesToTrack函数的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: HoughCircles 函数
- 下一篇: preCornerDetect函数
