对于我的研究,我正在研究使用openCV的可能性,现在我尝试使cv2.videoCapture(0)
具有图像读取功能,将其存储在缓冲区中或类似的东西中15秒钟,然后使用来自帧缓冲区的cv2.imshow()
在屏幕上显示它们。
我不知道如何缓冲我的视频提要,因为我希望能够延迟网络摄像头来为我的杂耍训练创建视频反馈系统。
因此,您需要做一些技巧,然后花几秒钟的时间到达屏幕,并获得我刚刚所做的反馈。
这是我目前捕获网络摄像头的方式,但这是非常基本的:
import cv2
cap = cv2.VideoCapture(0)
# Adding the frames to a buffer somewhere here in the script.
while True:
frame = cap.read()
cv2.imshow("frame", frame)
key = cv2.waitKey(1)
if key == 27:
break
cap.release()
cv2.destroyAllWindows()
给予的所有帮助和资源将不胜感激。
最佳答案
这是我结束了网络摄像头feed的视频播放的片段:(python)
它只是将帧存储在列表中,并在每个“DELAY_SECONDS”中弹出它们。
import cv2
import time
cap = cv2.VideoCapture(0)
print(cap.get(3))
print(cap.get(4))
start_time = time.time()
frames = []
DELAY_SECONDS = 5
while True:
ret, frame = cap.read()
frames.append(frame)
if time.time() - start_time > DELAY_SECONDS:
cv2.imshow("frame", frames.pop(0))
key = cv2.waitKey(1)
if key == 27:
break
感谢您的帮助,我的摘要如何帮助您!
关于python - 给视频捕获增加X延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58590615/