I have the following code for OpenCV templateMatch, a scan and a template (from a question I asked earlier here):
import cv2
import numpy as np
#load image into variable
img_rgb = cv2.imread('example_scan.jpg')
#load template
template = cv2.imread('example_template.jpg')
#read height and width of template image
w, h = template.shape[0], template.shape[1]
res = cv2.matchTemplate(img_rgb,template,cv2.TM_CCOEFF_NORMED)
threshold = 0.8
loc = np.where( res >= threshold)
for pt in zip(*loc[::-1]):
cv2.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0,255,0), 2)
img_rgb = cv2.resize(img_rgb,(800,600))
cv2.imwrite("example_result.png", img_rgb)
Template:
Okay so this works: templateMatch finds locations of the circles that look like the template. Perfect!
Now my question becomes: how certain is OpenCV that these locations found are correct? Let's say on a scale of 0% to 100%? I found something about minMaxLoc, but I don't know if this is what I'm looking for and what the results of minMaxLoc say, let alone how to use those values. I find the documentation not very clear to be honest.
So:
Is there a way to show how certain OpenCV is about the points found? Or how well it performed?
If yes, how?
I hope someone can help.
Regards, Ganesh