请参阅下面的代码部分,如何在videowriter和imagegrab命令中执行操作,以便无论我使用另一台PC /显示器,都始终具有全屏记录。
fourcc = cv2.VideoWriter_fourcc(*'XVID')
vid=cv2.VideoWriter(r"C:\\IQOutput\\123.avi", fourcc, 12, (1280,720) )
while(True):
img = ImageGrab.grab(bbox=(0,0,1280,720))
答案 0 :(得分:0)
回答我自己的问题,使用tkinter winfo来获取屏幕尺寸,然后将其放入视频编写器和imagegrab中:
import tkinter as tk
window = tk.Tk()
width = window.winfo_screenwidth()
height = window.winfo_screenheight()
fourcc = cv2.VideoWriter_fourcc(*'XVID')
vid=cv2.VideoWriter(r"C:\\IQOutput\\123.avi", fourcc, 12, (width, height))
while(True):
img = ImageGrab.grab(bbox=(0,0,width,height))