Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Mouse events in a mac?

Hello and thanks always.

I have written this very simple python program:

import cv2
import numpy as np

def draw_circle(event,x,y,flags,param):
    if event==cv2.EVENT_LBUTTONDBLCLK:
        cv2.circle(img,(x,y),100,(255,0,0),-1)

#create a black image, a windows and bind the fuction to the window

img=np.zeros((512,512,3),np.uint8)
cv2.namedWindow('image')
cv2.circle(img,(10,10),10,(0,255,0),-1)
cv2.setMouseCallback('image',draw_circle)

while(1):
    cv2.imshow('image',img)
    if cv2.waitKey(20)&0xFF==27:
        break

cv2.destroyAllWindows()

And although I have tested it on a windows machine and works without problems when I tried it on my mac, all I got is a black window and the program does not seem to respond to the mouse or pad commands.

What is my mistake here? Can anyone help me on this

Thanks a lot