image= cv2.imread('fullimage.jpg')
gray= cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
template= cv2.imread('staravia.png',0)
result= cv2.matchTemplate(gray, template, cv2.TM_CCOEFF)
min_val, max_val, min_loc, max_loc= cv2.minMaxLoc(result)
height, width= template.shape[:2]
top_left= max_loc
bottom_right= (top_left[0] + width, top_left[1] + height)
cv2.rectangle(image, top_left, bottom_right, (0,0,255),5)
cv2.imshow('staravia', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
So I'm using this code to identify this image:
But i'm getting
and this on another (same image but different template)
What I'm trying to achieve is to check if the image is inside the template or not correctly.