1

I am new to BoofCV, i was trying to implement BoofCV's Template Matching example given on following link http://boofcv.org/index.php?title=Example_Template_Matching.

It is working properly when my image contains the template, But when i change the image which is not containing the template still it returns result as match found.

So i want to do something like that it should give error or a log message that template not found instead of giving a match found that is totally wrong.

Thanks & Regards

Jigar Shah
  • 470
  • 1
  • 6
  • 13
  • So basicly it is not working in any case as the "valid" example you gave may be false-positive as well. – Antoniossss Nov 09 '16 at 09:43
  • Yes when image does not contain the template it gives wrong match, infact how it can get a match if the image is not containing the template. So I am trying to find a solution to check whether the image contains template or not if it contains then process else give some error message – Jigar Shah Nov 09 '16 at 09:54
  • That is my point - false-positive mean you dont know if match to the input where it should mach is caused because it actualy detect the template, or it is not working like in case of input where there is no template. In other workds, you dont know if it works at all. – Antoniossss Nov 09 '16 at 09:56
  • Yes so what can be done for detecting if the template is present is not. – Jigar Shah Nov 09 '16 at 10:01
  • I mean how to set a threshold value for template that if the match is < then threshold then template is detected else it is not found in image. – Jigar Shah Nov 09 '16 at 10:54

1 Answers1

1

You need to look at the match score. What makes a good threshold will depend on the matching technique you use.

matcher.process(image);
for( Match m : matcher.getResults().toList() ) {
    if( m.score < THRESHOLD ) // filter out false positives with this
        continue;
}
lessthanoptimal
  • 2,722
  • 2
  • 23
  • 25