I am trying to detect if an image is a 100 % match to being in another image, and then set a variable to True
if it is. But all the things I have read have turned up little to no results apart from one particular thread in which this code is given.
import cv2
method = cv2.TM_SQDIFF_NORMED
# Read the images from the file
small_image = cv2.imread('ran_away.png')
large_image = cv2.imread('pokemon_card.png')
result = cv2.matchTemplate(small_image, large_image, method)
# We want the minimum squared difference
mn,_,mnLoc,_ = cv2.minMaxLoc(result)
# Draw the rectangle:
# Extract the coordinates of our best match
MPx,MPy = mnLoc
# Step 2: Get the size of the template. This is the same size as the match.
trows,tcols = small_image.shape[:2]
# Step 3: Draw the rectangle on large_image
cv2.rectangle(large_image, (MPx,MPy),(MPx+tcols,MPy+trows),(0,0,255),2)
# Display the original image with the rectangle around the match.
cv2.imshow('output',large_image)
# The image is only displayed if we call this
cv2.waitKey(0)
However this opens up an output, and does stuff I do not want to do. All I want to do is to detect, if an image is in an image, and if it is, then print that to the console. In my particular circumstances, I am trying to detect if this image
is in this image
and if it is, print to the console that the pokemon has ran away.