import cv2
import numpy as np
drawing = False # true if mouse is pressed
ix,iy = -1,-1
def nothing(x):
pass
# mouse callback function
def draw_circle(event,x,y,flags,param):
global ix,iy,drawing
g = param[0]
b = param[1]
r = param[2]
shape = param[3]
if event == cv2.EVENT_LBUTTONDOWN:
drawing = True
ix,iy = x,y
elif event == cv2.EVENT_MOUSEMOVE:
if drawing == True:
if shape == 0:
cv2.rectangle(img,(ix,iy),(x,y),(g,b,r),-1)
else:
cv2.circle(img,(x,y),5,(g,b,r),-1)
elif event == cv2.EVENT_LBUTTONUP:
drawing = False
if shape == 0: <
import numpy as np
drawing = False # true if mouse is pressed
ix,iy = -1,-1
def nothing(x):
pass
# mouse callback function
def draw_circle(event,x,y,flags,param):
global ix,iy,drawing
g = param[0]
b = param[1]
r = param[2]
shape = param[3]
if event == cv2.EVENT_LBUTTONDOWN:
drawing = True
ix,iy = x,y
elif event == cv2.EVENT_MOUSEMOVE:
if drawing == True:
if shape == 0:
cv2.rectangle(img,(ix,iy),(x,y),(g,b,r),-1)
else:
cv2.circle(img,(x,y),5,(g,b,r),-1)
elif event == cv2.EVENT_LBUTTONUP:
drawing = False
if shape == 0: <