简体   繁体   English

错误消息“预期的 Ptr<cv::umat> 对于参数“垫子””</cv::umat>

[英]Error Message “Expected Ptr<cv::UMat> for argument 'mat'”

Just a standard Screen Grab code here:-这里只是一个标准的屏幕抓取代码:-

import numpy as np
import cv2
from PIL import ImageGrab

while True:
    Speed = np.array(ImageGrab.grab(bbox = (1060,510, 100, 60)))
    cv2.imshow('Speed' , Speed)
    

    if cv2.waitKey(25) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break

Returns the aforementioned error for the imshow line, What am I doing wrong?返回 imshow 行的上述错误,我做错了什么?

Your ImageGrab is not getting any images.您的ImageGrab没有获取任何图像。 Take a look at Speed.shape , it'll be an empty tuple () .看一下Speed.shape ,它将是一个空元组() There's an issue with your bbox.你的bbox有问题。

import numpy as np
import cv2
from PIL import ImageGrab

while True:
    # your bbox order or params was wrong: left_x, left_y, right_x and right_y
    Speed = np.array(ImageGrab.grab(bbox = (100, 60, 1060, 510)))
    cv2.imshow('Speed' , Speed)
    

    if cv2.waitKey(25) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM