Ask Your Question
0

Quit if There's No Match

asked 2016-06-20 02:41:20 -0600

EkremE gravatar image

Hello everyone, I'm working on a image-processing project with Java, Appium on mobile devices. In the code, I'm using Canny edge detector for template matching. But if there's no templae in image, it always finds a match. What I want to do is; if there's no matching, the code should give an exception. Are there any controls about it?

edit retag flag offensive close merge delete

Comments

Do you use the Template Matching Function in OpenCV or another algorithm? I'm not very familiar with it, but if i'm right you get a matrix back which indicates where the highest matches were detected. So maybe you could use a threshold value for the detected maximum matching value.

Missing gravatar imageMissing ( 2016-06-20 04:03:15 -0600 )edit

I'm using OpenCV template-matching algorithm (TM_CCOEFF or TM_CCOEFF_NORMED). Actually I don't know well how should I change thresholds. I mean I've tried threshold and adaptive_threshold but obviously I couldn't make it.

EkremE gravatar imageEkremE ( 2016-06-20 05:13:24 -0600 )edit

Template matching returns a grayscale image where each pixel denotes how much the neighbourhood of that pixel matches with the template. With minMaxLoc() you get the point with the best match. You now could simply check this maximum point and if it is below a certain value (you specif this value) you throw an exception. I never used template matching on my own, so this is just an idea to solve this your issue.

Missing gravatar imageMissing ( 2016-06-20 06:19:43 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-06-27 09:32:29 -0600

EkremE gravatar image

updated 2016-06-27 09:32:40 -0600

I did some research about thresholding and they say I need to specify a threshold value between 0 and 1 then compare it with maxValue (for TM_CCOEFF). But my maxValue is always over 1.0 if there's match or not. How should I specify threshold / minMaxValue ?? minMaxLoc is not useful for me, I have a long test run and every image's location is different.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-06-20 02:41:20 -0600

Seen: 346 times

Last updated: Jun 20 '16