OpenCV with python(MAC OS X EL Capitan)
I'm creating a demo project to track mouse events in openCV. using standard mouseCallback from openCV.
following is my code for the same.
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')
with this implementation i'm always getting mouse down and mouseup event and only single click event. i'm unable to get double click event(EVENT_LBUTTONDBLCLK). value for this constant is 7.