2014-02-09 131 views
1

我新的圖像處理,在我的應用我使用模板匹配檢測眼睛虹膜,所以我字符串標準光圈和執行模板匹配,代碼如下獲取使用模板匹配時,匹配百分比值

CvInvoke.cvMatchTemplate(grayframeright_1.Ptr, templateimagegray.Ptr, templateimagesults.Ptr, TM_TYPE.CV_TM_CCORR_NORMED); 

templateimagesults.MinMax(out min, out max, out Min_Loc, out MAX_Loc); 

          Location = new Point((MAX_Loc[0].X), (MAX_Loc[0].Y)); 
給出

問題是有些時候我得到誤報,爲了消除誤報,我打算計算/得到匹配百分比值,並使用適當的條件。

1)那麼emgucv/opencv中有沒有函數來獲得匹配的百分比值? 例如 - 50%,80%等

2)是否有其他方法可以消除誤報?

請幫我弄清楚這一點。

在此先感謝

回答

0
  1. 它認爲在尊重位置的位置templateimagesults.Ptr值是你想匹配的百分比,它與窗口圖像模板在特定的相似度值位置。參考:http://docs.opencv.org/modules/imgproc/doc/object_detection.html

  2. 減少誤報和改善召回總是在這些工作中保持平衡,您不應該只關注減少誤報。也許你可以嘗試使用標準的機器學習框架對象檢測

0

「的OpenCV模板匹配」實際上不提供文件來確定匹配百分比值,但是,如果你真的想從匹配獲得精度,也許你可以使用下面的方法:

double maxThd = 0.7; 
    double minThd = 0.3; 

    matchTemplate(img, templ, result, match_method); 
    normalize(result, result, 0, 1, NORM_MINMAX, -1, Mat()); 

    /// Localizing the best match with minMaxLoc 
    double minVal; double maxVal; Point minLoc(-1,-1); Point maxLoc(-1,-1); 
    Point matchLoc; 

    minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, Mat()); 

    /// For SQDIFF and SQDIFF_NORMED, the best matches are lower values. For all the other methods, the higher the better 
    if(match_method == CV_TM_SQDIFF_NORMED && minVal < minThd) 
    { matchLoc = minLoc; } 
    else if(match_method == CV_TM_CCORR_NORMED && maxVal > maxThd) 
    { matchLoc = maxLoc; } 

    bool isMatch = matchLoc != cv::Point(-1,-1); 
    if(isMatch) { 
    // Show the result here! 
    } 

而且更多信息,你可以參考

opencv的模板匹配

的建議機器學習教程

高級圖像匹配,請參閱matchine學習,例如你的答案神經網絡

+0

比你多,這是非常有價值的,可以請你解釋一下,爲什麼我們使用此代碼CV ::點(-1,-1)? – gouthaman93

+0

ok!也許新版本更容易理解。它意味着模板對象是在「matchLoc!= cv :: Point(-1,-1)」成立時從測試圖像中找到的,爲什麼使用cv :: Point(-1,-1),因爲我將所有matchLoc(minLoc,maxLoc)初始化爲非真實點(-1,-1)以確定對象是否存在或不存在! – RyanLiu

+0

非常清楚的解釋,我也想知道爲什麼我們使用這個代碼'normalize(result,result,0,1,NORM_MINMAX,-1,Mat());' ,我搜查了一些文件,但不明白... 請不要誤解我的要求更多的解釋。 – gouthaman93