I am writing a program that will take a screenshot every few seconds then attempt to template match this screenshot with a predetermined template. However, if I were to attempt to do an if statement, how would I write that? How can I determine whether the templateMatch actually succeeded or not?
Source Code:
import cv2 as cv
import time
import pyautogui
import os
template = cv.imread('C:\\Users\\Bran\\Pictures\\ovw_focus_point.jpg',0)
w, h = template.shape[::-1]
while True:
time.sleep(5)
sc = pyautogui.screenshot()
os.remove('C:\\Users\\Bran\\Pictures\\OWSC\\test-1.png')
sc.save('C:\\Users\\Bran\\Pictures\\OWSC\\test-1.png')
print('one loop')
img = cv.imread('C:\\Users\\Bran\\Pictures\\OWSC\\test-1.png',0)
method = eval('cv.TM_CCOEFF')
res = cv.matchTemplate(img,template,method)
I'm not sure how to structure my code from this point. I plan to have the program perform a function once there is a successful template match. Hope someone can help!