TypeError:参数'image'的预期cv :: UMat
我正在截屏,我需要捕获屏幕发送的内容。
要制作有效的图像,您需要(vid = cv2.VideoWriter('record.avi', fourcc, 8, (500,490)) )
,问题是需要从图像尺寸中减去偏移量。而且我只想要20或20的图像,并需要它来捕捉屏幕的一分钱。
我尝试放入负数。我还厌倦了从x-w和y-h减去减法。
import numpy as np
import cv2
from PIL import ImageGrab
fourcc = cv2.VideoWriter_fourcc('X','V','I','D') #you can use other codecs as well.
vid = cv2.VideoWriter('record.avi', fourcc, 8, (500,490))#This is the problem area
while(True):
img = ImageGrab.grab(bbox=(100, 10, 600, 500)) #x, y, w, h . This is the problem area
img_np = np.array(img)
#frame = cv2.cvtColor(img_np, cv2.COLOR_BGR2GRAY)
vid.write(img_np)
cv2.imshow("frame", img_np)
vid.release()
cv2.destroyAllWindows()
我收到的错误消息是:
TypeError:参数'image'的预期cv :: UMat