Python opencv 鼠标点击图片,返回坐标

import cv2
img = cv2.imread(’./data/cat.png’)

def on_EVENT_LBUTTONDOWN(event, x, y, flags, param):
if event == cv2.EVENT_LBUTTONDOWN:
xy = “%d,%d” % (x, y)
print(‘x, y = {}, {}’.format(x, y))
cv2.circle(img, (x, y), 1, (255, 0, 0), thickness=-1)
cv2.putText(img, xy, (x, y), cv2.FONT_HERSHEY_PLAIN,
1.0, (0, 0, 0), thickness=1)
cv2.imshow(“image”, img)

cv2.namedWindow(“image”)
loc = cv2.setMouseCallback(“image”, on_EVENT_LBUTTONDOWN)
cv2.imshow(“image”, img)
cv2.waitKey(0)

你可能感兴趣的:(手势识别)