An image opens on running my code in terminal or in Spyder. But there is no action on doing either left or right click. Here is the code I've written:
import cv2
import matplotlib.pyplot as plt
def drawCircle(event,x,y,flags,param):
if event == cv2.EVENT_LBUTTONDOWN: #(If Left button of mouse clicked)
cv2.circle(img,(x,y),radius = 100, color =(255,0,0),thickness=-1)
if event == cv2.EVENT_RBUTTONDOWN: #(If Right button of mouse clicked)
cv2.circle(img,(x,y),radius = 100, color =(0,255,0),thickness=-1)
img= np.zeros(shape=(512,512,3),dtype=np.int8)
cv2.namedWindow("someimage")
cv2.setMouseCallback("someimage", drawCircle)
while True:
cv2.imshow("someimage",img)
if cv2.waitKey(2):
break
cv2.destroyAllWindows()