类型错误:在 python 中使用 mss 库的参数“mat”的预期 Ptr<cv::UMat>

问题描述

我正在尝试使用 mss 库添加屏幕截图并使用以下代码显示它,但每次都会出现相同的错误。 这个错误有没有解决办法

TypeError: 参数 'mat' 的预期 Ptr<:umat>

** 我在 Macos 而非 windows 中使用这个

import cv2 as cv
import numpy as np
import os
from time import time
from mss import mss

os.chdir(os.path.dirname(os.path.abspath(__file__)))

loop_time = time()
with mss() as sct:
    while (True):
        
        monitor_1 = sct.monitors[1]  # Identify the display to capture
        screenshot = sct.grab(monitor_1)
        
        cv.imshow('result',screenshot)
        
        print('FPS {}',format(1 / (time() - loop_time)))
        loop_time = time()
        
        if cv.waitKey(1) == ord('q'):
            cv.destroyAllWindows()
            break
    

print('done')

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)