Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

please convert your img from the webcam to grayscale, so both have the same type:

while 1:
    _,img=cam.read()
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # !!
    res = cv2.matchTemplate(gray, template,method)
    min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
    ...