|
|
@ -46,12 +46,12 @@ assert template is not None, "file could not be read, check with os.path.exists( |
|
|
|
w, h = template.shape[::-1] |
|
|
|
w, h = template.shape[::-1] |
|
|
|
|
|
|
|
|
|
|
|
# All the 6 methods for comparison in a list |
|
|
|
# All the 6 methods for comparison in a list |
|
|
|
methods = ['cv.TM_CCOEFF', 'cv.TM_CCOEFF_NORMED', 'cv.TM_CCORR', |
|
|
|
methods = ['TM_CCOEFF', 'TM_CCOEFF_NORMED', 'TM_CCORR', |
|
|
|
'cv.TM_CCORR_NORMED', 'cv.TM_SQDIFF', 'cv.TM_SQDIFF_NORMED'] |
|
|
|
'TM_CCORR_NORMED', 'TM_SQDIFF', 'TM_SQDIFF_NORMED'] |
|
|
|
|
|
|
|
|
|
|
|
for meth in methods: |
|
|
|
for meth in methods: |
|
|
|
img = img2.copy() |
|
|
|
img = img2.copy() |
|
|
|
method = eval(meth) |
|
|
|
method = getattr(cv, meth) |
|
|
|
|
|
|
|
|
|
|
|
# Apply template Matching |
|
|
|
# Apply template Matching |
|
|
|
res = cv.matchTemplate(img,template,method) |
|
|
|
res = cv.matchTemplate(img,template,method) |
|
|
|