I am using the pyautogui library to take a screenshot, which gets stored as PIL.Image.Image. When I try to use cv2's cvtColor() function to convert it, I get a TypeError:
TypeError: Expected Ptr<cv::UMat> for argument 'src'
Here is my code:
img = pyautogui.screenshot(0, 0, 500, 500)
print(type(img)) #<class 'PIL.Image.Image'>
img_rgb = numpy.array(img)
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
What is my mistake here, and how could I convert the image as desired?