i am doing a template matching
now,what i want to do is find the accuracy of template matching
I have done template matching, but how do i get the accuracy
i think i have to subtract the matched region and template image.
how do i achieve this
CODE
import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt
img = cv.imread('image.jpg',0)
img1 = img.copy()
template = cv.imread('template.jpg',0)
w, h = template.shape[::-1]
method = ['cv.TM_CCOEFF_NORMED','cv.TM_CCORR_NORMED']
for meth in method:
img = img1.copy()
method = eval(meth)
res = cv.matchTemplate(img,template,method)
min_val, max_val, min_loc, max_loc = cv.minMaxLoc(res)
bottom_right = (top_left[0] + w, top_left[1] + h)
cv.rectangle(img,top_left, bottom_right, 255, 2)
plt.subplot(121)
plt.imshow(res,cmap = 'gray')
plt.title('Matching Result')
plt.subplot(122)
plt.imshow(img,cmap = 'gray')
plt.title('Detected Point')
plt.show()