第一步,输入图片,点击能获得图片中一点的坐标
效果如图
用鼠标的左点击事件
import cv2
import math
path = 'img02.png'
img = cv2.imread(path)
pointList = []
def mousepoints(event,x,y,flags,params):
if event == cv2.EVENT_LBUTTONDOWN:
cv2.circle(img,(x,y),5,(0,0,255),cv2.FILLED)
pointList.append([x,y])
print(pointList)
print(x,y)
while True:
cv2.imshow('img',img)
cv2.setMouseCallback('img',mousepoints)
if cv2.waitKey(1) & 0xFF == ord('q'):
pointList = []
img = cv2.imr