Ask Your Question

Revision history [back]

Hello, i'm learning the basics of opencv. I am working with the bit of code below. I generates a black image, i cannot click in some areas of the image without getting an error. Can anyone say why?

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()

click to hide/show revision 2
None

updated 2020-11-15 10:02:09 -0600

berak gravatar image

Hello, i'm learning the basics of opencv. I am working with the bit of code below. I It generates a black image, i cannot click in some areas of the image without getting an error. Can anyone say why?why? seems to work ok on images that have the same value for x & y.

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

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)

y) img = np.zeros((577, 433, 3), np.uint8)

np.uint8) print(img.shape) cv2.imshow('image', img) cv2.setMouseCallback('image', click_event)

click_event) cv2.waitKey(0) cv2.destroyAllWindows()

cv2.destroyAllWindows()
click to hide/show revision 3
retagged

updated 2020-11-15 10:02:40 -0600

berak gravatar image

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.

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()
click to hide/show revision 4
None

updated 2020-11-15 10:03:18 -0600

berak gravatar image

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.

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()