我正在使用Python和OpenCV进行一些视觉应用.我需要在变量中保存鼠标位置,我不知道如何.我可以将当前鼠标位置打印到窗口中,但不能将其保存到变量中.
我的问题类似于这个只有我在python中工作: OpenCV从鼠标回调函数返回值
我这样定义我的函数(用于打印鼠标位置):
def mousePosition(event,x,y,flags,param):
if event == cv2.EVENT_MOUSEMOVE:
print x,y
Run Code Online (Sandbox Code Playgroud)
我在我的程序中使用它,如下所示:
cv2.setMouseCallback('Drawing spline',mousePosition)
Run Code Online (Sandbox Code Playgroud)