python - Clicking on image after I find it with template matching OpenCV -


recently i've been playing opencv.

i wrote small program find image in picture take on screen. find images expect, try move mouse location found these same points. mouse goes bottom right of screen, kind of confuses me. ( based program based on 1 mario coins here)

import cv2 import numpy np matplotlib import pyplot plt import pyscreenshot imagegrab import tkinter tk import time import pyautogui  im=imagegrab.grab() imagegrab.grab_to_file('current.png') print "done image"  img_rgb = cv2.imread('current.png') img_gray = cv2.cvtcolor(img_rgb, cv2.color_bgr2gray) template = cv2.imread('coin.png',0) w, h = template.shape[::-1]  res = cv2.matchtemplate(img_gray,template,cv2.tm_ccoeff_normed) threshold = 0.8 loc = np.where( res >= threshold) counter=0 pt in zip(*loc[::-1]):     cv2.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0,0,255), 2)     counter=counter+1 print counter cv2.imwrite('res.png',img_rgb)  pt in zip(*loc[::-1]):     pyautogui.moveto(pt)     print "---"     #time.sleep(.5) 

basically find mouse isn't moving points want to( place found image). feel i'm missing easy - can give me tips?


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -