Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何让用户在图像上设置4点?_Python_Python 3.x_User Interface_Image Processing - Fatal编程技术网

Python 如何让用户在图像上设置4点?

Python 如何让用户在图像上设置4点?,python,python-3.x,user-interface,image-processing,Python,Python 3.x,User Interface,Image Processing,我想用Python制作一个工具,允许用户在图像上设置4个点,然后以如下格式返回图像上点的位置: [[240, 250], [220, 1205], [500, 260], [549, 1206]] Python 3.8.x | Windows 10试试看 points=[] def click_event(event, x, y, flags, params): if event == cv2.EVENT_LBUTTONDOWN: cv2.circl

我想用Python制作一个工具,允许用户在图像上设置4个点,然后以如下格式返回图像上点的位置:


[[240, 250], [220, 1205], [500, 260], [549, 1206]]


Python 3.8.x | Windows 10

试试看

points=[]
def click_event(event, x, y, flags, params): 
      
    if event == cv2.EVENT_LBUTTONDOWN: 
        cv2.circle(img,(x,y),5,(0,0,255),-1)
        font = cv2.FONT_HERSHEY_SIMPLEX 
        cv2.putText(img,str(x)+','+str(y),(x,y), font,1,(255, 0, 0),2) 
        cv2.imshow('image', img) 
        points.append((x, y))

img = cv2.imread('foto.jpg') 
cv2.imshow('image', img) 

cv2.setMouseCallback('image', click_event) 
cv2.waitKey(0)
cv2.destroyAllWindows()

这些点的轴的原点在哪里?居中左下角?左上角谢谢你的帮助