gpt4 book ai didi

python - python中的屏幕录像机

转载 作者:太空宇宙 更新时间:2023-11-03 11:34:34 25 4
gpt4 key购买 nike

是否有用于在 python 中制作屏幕录像机应用程序的库?我认为制作那样的东西会很有趣。但是一个可以使用 ubuntu 在 linux im 上运行的库

谢谢!

最佳答案

使用 MSS 是使用 python 进行屏幕录制的绝佳选择。

例如,使用来自 http://python-mss.readthedocs.io/examples.html 的代码,我的平均帧率为 60。

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: {0}'.format(1 / (time.time()-last_time)))

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

关于python - python中的屏幕录像机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8074595/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com