Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
类型错误:预期的Ptr<;cv::UMat>;对于参数';垫';在python中使用mss库_Python_Opencv_Python Mss - Fatal编程技术网

类型错误:预期的Ptr<;cv::UMat>;对于参数';垫';在python中使用mss库

类型错误:预期的Ptr<;cv::UMat>;对于参数';垫';在python中使用mss库,python,opencv,python-mss,Python,Opencv,Python Mss,我试图截图使用mss库添加显示它使用下面的代码,但每次都得到相同的错误。 是否有此错误的修复程序 TypeError:参数“mat”应为Ptr **我在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 =

我试图截图使用mss库添加显示它使用下面的代码,但每次都得到相同的错误。 是否有此错误的修复程序

TypeError:参数“mat”应为Ptr

**我在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')
您必须将“屏幕截图”转换为cv::UMat:

import time

import cv2
import mss
import numpy


with mss.mss() as sct:
    # Part of the screen to capture
    monitor = {"top": 40, "left": 0, "width": 800, "height": 640}

    while "Screen capturing":
        last_time = time.time()

        # Get raw pixels from the screen, save it to a Numpy array
        img = numpy.array(sct.grab(monitor))

        # Display the picture
        cv2.imshow("OpenCV/Numpy normal", img)

        # Display the picture in grayscale
        # cv2.imshow('OpenCV/Numpy grayscale',
        #            cv2.cvtColor(img, cv2.COLOR_BGRA2GRAY))

        print("fps: {}".format(1 / (time.time() - last_time)))

        # Press "q" to quit
        if cv2.waitKey(25) & 0xFF == ord("q"):
            cv2.destroyAllWindows()
            break
这是来自

的示例,您必须将“屏幕截图”转换为cv::UMat:

import time

import cv2
import mss
import numpy


with mss.mss() as sct:
    # Part of the screen to capture
    monitor = {"top": 40, "left": 0, "width": 800, "height": 640}

    while "Screen capturing":
        last_time = time.time()

        # Get raw pixels from the screen, save it to a Numpy array
        img = numpy.array(sct.grab(monitor))

        # Display the picture
        cv2.imshow("OpenCV/Numpy normal", img)

        # Display the picture in grayscale
        # cv2.imshow('OpenCV/Numpy grayscale',
        #            cv2.cvtColor(img, cv2.COLOR_BGRA2GRAY))

        print("fps: {}".format(1 / (time.time() - last_time)))

        # Press "q" to quit
        if cv2.waitKey(25) & 0xFF == ord("q"):
            cv2.destroyAllWindows()
            break
这是我们的例子