Answer the question
In order to leave comments, you need to log in
How to fix error when changing color space (python 3, OpenCV)?
Hello, dear pythonists) Please tell me, I can’t color the screenshot.
The code is quite simple:
box = (0, 170, 650, 1000)
img = ImageGrab.grab(box)
imgGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
Expected cv::UMat for argument 'src'
gray = cv2.cvtColor(cv2.UMat(img), cv2.COLOR_RGB2GRAY)
UMat() missing required argument 'ranges' (pos 2)
None
Expected cv::UMat for argument 'm'
Answer the question
In order to leave comments, you need to log in
I don't know how practical this is, but you can first download the image to disk, and then re-open it with cv2
box = (0, 170, 650, 1000)
img = ImageGrab.grab(box)
img.save("picture.jpg")
image = cv2.imread("picture.jpg")
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.imwrite("gray.jpg", gray)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question