python beginner mouseclicking problem
Hello, i'm learning the basics of opencv. I am working with the bit of code below. It generates a black image, i cannot click in some areas of the image without getting an error. Can anyone say why? seems to work ok on images that have the same value for x & y.
import cv2
import numpy as np
def click_event(event, x, y, flags, param):
if event == cv2.EVENT_LBUTTONDOWN:
blue = img[x, y, 0]
green = img[x, y, 1]
red = img[x, y, 2]
print(blue, ' ', green, ' ', red)
print(x, ' ', y)
img = np.zeros((577, 433, 3), np.uint8)
print(img.shape)
cv2.imshow('image', img)
cv2.setMouseCallback('image', click_event)
cv2.waitKey(0)
cv2.destroyAllWindows()