How to read a mouse left click event in python?
For example, I would like to make a code like this:
while True:
[...]
if <left mouse button is clicked>:
print("Left Mouse has been clicked")
[...]
cv2.destroyAllWindows
I've read the "Mouse as a Paint-Brush", but it does not explain how to have Python only recognize the mouse left click event.
I'd appreciate any help I can get.
I'd tried modifying the code from the tutorial to suit my needs, but I can't seem to get the code to work:
def mouse(event,x,y,flags,param):
if event == cv2.EVENT_LBUTTONDBLCLK:
return True
[...]
cap = cv2.VideoCapture(0)
while True:
[...]
if cv2.setMouseCallback('frame', mouse)==True
mouse)==True:
print("Left Mouse Button has been clicked")
[...]
cv2.destroyAllWindows
cv2.destroyAllWindows