Quit if There's No Match
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?
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.
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.
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.