I have been working on opencv and have passed through cv2.setMouseCallback() . Following is the code for drawing circles on mouse click .
import cv2
import numpy as np
def draw_circle(event,x,y,flags,param):
if event == cv2.EVENT_LBUTTONDBLCLK:
cv2.circle(image,(x,y),(100,100),(255,0,0),-1)
img = np.zeros((512,512,3), np.uint8)
cv2.namedWindow("image")
cv2.setMouseCallback("image",draw_circle)
while True:
cv2.imshow("image",image)
if cv2.waitKey(1) & 0xFF == ord("q"):
break
cv2.destroyAllWindows()`
please explain
- How can function draw_circle can be called without passing all his arguments
- there are five arguments in function and there are only two variables which can be assigned values
- what is the purpose of creating cv2.namedWindow("image")
THANKS!