I am trying to get this code below working.
It is grabbing a screen shot and attempting to show just one part of the resulting image.
from PIL import ImageGrab
import numpy as np
import cv2
img = ImageGrab.grab(bbox=(320,190,1500,800))
img_np = np.array(img)
cropped = img_np[10:10, 10:10]
cv2.imshow("cropped", cropped)
cv2.waitKey(0)
cv2.destroyAllWindows()
It returns the error below
Traceback (most recent call last):
File "/home/nono/Desktop/tmp/belote/t.py", line 8, in <module>
cv2.imshow("cropped", cropped)
cv2.error: OpenCV(4.5.4) ./modules/core/src/array.cpp:2494: error: (-206:Bad flag (parameter or structure field)) Unrecognized or unsupported array type in function 'cvGetMat'
Would you be able to tell what is wrong here? How can I get my cropped image to show with cv2?
(obviously cropping directly from ImageGrab is not an option as I have plan for multiple crop later).