簡體   English   中英

錯誤消息“預期的 Ptr<cv::umat> 對於參數“墊子””</cv::umat>

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

這里只是一個標准的屏幕抓取代碼:-

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

返回 imshow 行的上述錯誤,我做錯了什么?

您的ImageGrab沒有獲取任何圖像。 看一下Speed.shape ,它將是一個空元組() 你的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