Raj*_*mar 11 opencv python-3.x
我正在创建一个演示项目来跟踪openCV中的鼠标事件.使用openCV的标准mouseCallback.
以下是我的相同代码.
drawWithMouse.py
#!/usr/local/bin/local/python3
import numpy as np
import cv2 as cv
#Mouse callback function
def draw_shape(event,x,y,flags,param):
print("event : ",event)
if event == cv.EVENT_LBUTTONDBLCLK:
cv.circle(img,(x,y),100,(255,0,0),-1)
#Create a black image, a window and bind the function to the window
img = np.zeros((780,780,3),np.uint8)
cv.namedWindow('DrawWithMouse')
cv.setMouseCallback('DrawWithMouse',draw_shape)
while(1):
cv.imshow('DrawWithMouse',img)
if cv.waitKey(10) & 0xFF == 27: #ANDing with 0xFF as my machine is 64 bit
break
cv.destroyWindow('DrawWithMouse')
Run Code Online (Sandbox Code Playgroud)
有了这个实现,我总是得到鼠标按下和mouseup事件,只有单击事件.我无法获得双击事件(EVENT_LBUTTONDBLCLK).这个常数的值是7.
| 归档时间: |
|
| 查看次数: |
1575 次 |
| 最近记录: |