opencv - 在特定 FPS 下使用 opencv 从网络摄像头抓取图像
问题描述
是否有允许我以特定帧速率抓取静止图像的 OpenCV 功能。就像我可以告诉这个函数以 10fps 的速度抓取 5 张图像一样,它会以 0.1 秒的精确间隔拍摄 5 张图像。
如果不是什么是实现这一目标的好方法?我目前的尝试是不断抓取图像,并且仅在上一帧后 0.1 秒但不准确的 10fps 时才保存
afterNextFrame = False
while x < 20:
now = time.monotonic()
if now >= nextFrame:
afterNextFrame = True
if afterNextFrame == True:
cameraCap.grab()
print("\nNow: ", now, "\n")
_, frame = cameraCap.retrieve()
# save frame here
nextFrame += 0.1 # wait 0.1 second for 10 fps
afterNextFrame = False
解决方案
推荐阅读
- symfony - Symfony 4 - Webpack Encore 的错误资产路径
- javascript - 数据表为包含搜索项的所有行着色
- delphi - Delphi FMX TTreeView 参数超出范围异常
- java - 上传后刷新和图像而不刷新整个页面Java反应
- linux - 在 vm 共享文件夹中编译 ONOS 时权限被拒绝
- node.js - Mikro-orm 教程 - Ben Awad lireddit - 尝试运行第一次迁移
- python - 为什么 multiprocessing.Process 在这里不起作用?
- python - 将对象分配给多对多关系 - Django
- java - 从 Springboot 2.1.4.RELEASE 升级到 2.5.0 在运行时给出 IllegalArgumentException
- python - 如何在 selenium python 中运行多个 chrome?