Get matching percentage value when using Template matching

I am new to image processing , In my application i am detecting eye iris using template matching , So i string a standard iris and performing template matching ,The code is given below

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));

The problems is some times i get false positives , in order to eliminate false positive , i planned to calculate/get matching percentage value and use appropriate if condition.

1)So are there any functions in emgucv/opencv to get the matching percentage value? for e.g - 50% , 80% and etc

2)Are there any other ways to eliminate false positives ?

Please help me to figure this out .

Thanks in advance

Answers


  1. it think the value in templateimagesults.Ptr at the location of respected location is the matching percentage you want, it is the similarity value of the template with the windowed image at the specific location. refer to: http://docs.opencv.org/modules/imgproc/doc/object_detection.html

  2. reducing false positives and improve recalling is always balanced in these job, you should not just focus on reducing false positives. maybe you can try to using standard machine learning framework for object detecting


"opencv template matching" actually does not provide the document to determine the matching percentage value, however, if you really want to get the accuracy from matching, maybe you can use following method:

  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!
  }

And the more information, you can refer to

Opencv Template Matching

The recommend Machine Learning Tutorial

Advance image matching, pls refer to matchine learning, e.g. neural network


Need Your Help

Can I use cache manifest while I am online?

html html5 cache-manifest

I need to store my js files on browser to reduce load time.

How to make the other line move forward in the dynamic graph?

javascript html graph

below is the link to code regarding to dynamic graph. I am having a problem of making the red line, being updated and move forward together with the blue line.. I don't know where the problem is that