From d17387f6dadbd1ca56b27f3447bea4a3dae19b48 Mon Sep 17 00:00:00 2001 From: prateekchachra Date: Wed, 5 Sep 2018 22:38:31 +0530 Subject: [PATCH] Change for bug in template.shape template is already a grayscale image, so unpacking it only needs the output w and h. There is no need for the array handing being done. --- Tuts/template_matching.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tuts/template_matching.py b/Tuts/template_matching.py index a7044f6..d0caf12 100644 --- a/Tuts/template_matching.py +++ b/Tuts/template_matching.py @@ -12,7 +12,7 @@ img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY) template = cv2.imread('opencv-template-for-matching.jpg',0) -w, h = template.shape[::-1] +w, h = template.shape res = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED) threshold = 0.8 @@ -23,4 +23,4 @@ cv2.imshow('Detected', img_rgb) cv2.waitKey(0) -cv2.destroyAllWindows() \ No newline at end of file +cv2.destroyAllWindows()