-1

I tried to remove the part I got the result but only in reverse order. So my question here is that why are we using that part to splice the array.

import numpy as np
import cv2

img = cv2.imread("E:/tmp/pis.jpg")
template = cv2.imread("E:/tmp/pi templates.jpg",0)

img_gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
w,h = template.shape[::-1]

res = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED)
threshold = 0.6

loc = np.where(res>=threshold)

for pt in zip(*loc[::-1]):
    cv2.rectangle(img,pt,(pt[0]+w,pt[1]+h),(255,255,255),1)

cv2.imshow("img",img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Patrick Artner
  • 50,409
  • 9
  • 43
  • 69

1 Answers1

-1

that's not for slicing if that's what you meant. [::-1] is used to reverse lists

l = [1,2,3]
l = l[::-1]
print(l) # [3, 2, 1]
lalam
  • 195
  • 1
  • 11