Get the coordinates of a found object using a template. [closed]

asked 2019-05-23 12:53:29 -0600

So this is my code:

import cv2
import numpy as np
import pyautogui

img_bgr =  cv2.imread('gra.png')
img_gray = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2GRAY)

template = cv2.imread('bones2.png', 0)

w, h = template.shape[:: -1]

res = cv2.matchTemplate(img_gray, template, cv2.TM_CCOEFF_NORMED)
threshhold = 0.90
loc = np.where( res >= threshhold)
for pt in zip(*loc[:: -1]):
    cv2.rectangle(img_bgr, pt, (pt[0] + w, pt[1] + h),(0, 255, 255), 2 )

cv2.imshow('znalezione', img_bgr)

pyautogui.moveTo( ? , ? ,duration=0.5)                                      <======== problem

my question is how can i get the coors of that object

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2019-05-23 13:12:59.730430

Comments

1

we can't help with pyautogui (if that was ypur problem)

then i somehow doubt, that you understood any of the code above.

berak gravatar imageberak ( 2019-05-23 13:13:58 -0600 )edit

you are perfectly right! I dont at all

stasiek gravatar imagestasiek ( 2019-05-23 13:41:43 -0600 )edit
1

don't ask then, or risk looking like an idiot.

berak gravatar imageberak ( 2019-05-23 13:44:47 -0600 )edit