Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.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
屏幕捕获python 3.6.6 opencv和枕头不工作_Python_Python 3.x_Opencv_Python Imaging Library - Fatal编程技术网

屏幕捕获python 3.6.6 opencv和枕头不工作

屏幕捕获python 3.6.6 opencv和枕头不工作,python,python-3.x,opencv,python-imaging-library,Python,Python 3.x,Opencv,Python Imaging Library,我试图做屏幕截图,它只是提供了一个黑屏 这是我的密码: import numpy as np from PIL import ImageGrab import cv2 while(True): printscreen_pil = ImageGrab.grab(bbox=(781, 925, 814, 941)) printscreen_numpy = np.array(printscreen_pil.getdata(),dtype='uint8')\ .resha

我试图做屏幕截图,它只是提供了一个黑屏

这是我的密码:

import numpy as np
from PIL import ImageGrab
import cv2

while(True):
    printscreen_pil =  ImageGrab.grab(bbox=(781, 925, 814, 941))
    printscreen_numpy =   np.array(printscreen_pil.getdata(),dtype='uint8')\
    .reshape((printscreen_pil.size[1],printscreen_pil.size[0],3)) 
    cv2.imshow('window',printscreen_numpy)



    if cv2.waitKey(25) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break
请注意,bbox是(x1,y1,x2,y2),所以(781,925,814,941)是一个窄屏幕

这是我的例子:

screen_w = 1920
screen_h = 1080 

while True:
    rgb = ImageGrab.grab(bbox=(0, 0, screen_w, screen_h)) #x1, y1, x2, y2
    rgb = np.array(rgb)

    cv2.imshow('window_frame', rgb)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
请注意,bbox是(x1,y1,x2,y2),所以(781,925,814,941)是一个窄屏幕

这是我的例子:

screen_w = 1920
screen_h = 1080 

while True:
    rgb = ImageGrab.grab(bbox=(0, 0, screen_w, screen_h)) #x1, y1, x2, y2
    rgb = np.array(rgb)

    cv2.imshow('window_frame', rgb)

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

ImageGrab.grab的通道数为4,因此“重塑((打印屏幕大小[1],打印屏幕大小[0],4])”应该有效ImageGrab.grab的通道数为4,因此“重塑((打印屏幕大小[1],打印屏幕大小[0],4])”应该有效