opencv - USB 网络摄像头和可用格式
问题描述
我有一个 ELP USB 相机。可用的格式有:
$ v4l2-ctl --list-formats-ext -d /dev/video1
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture
[0]: 'MJPG' (Motion-JPEG, compressed)
Size: Discrete 1920x1080
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 1024x768
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.008s (120.101 fps)
Size: Discrete 800x600
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 1280x1024
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 320x240
Interval: Discrete 0.008s (120.101 fps)
[1]: 'YUYV' (YUYV 4:2:2)
Size: Discrete 1920x1080
Interval: Discrete 0.167s (6.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.111s (9.000 fps)
Size: Discrete 1024x768
Interval: Discrete 0.167s (6.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 800x600
Interval: Discrete 0.050s (20.000 fps)
Size: Discrete 1280x1024
Interval: Discrete 0.167s (6.000 fps)
Size: Discrete 320x240
Interval: Discrete 0.033s (30.000 fps)
假设我想使用 MJPG 1280x720 @ 20fps,甚至像 1280x720 @ 18fps 这样奇怪的东西。
这个答案说:
v4l2 仅支持列出的格式,其他任何内容都需要用户编码,并且很少提供 RGB,尽管几乎所有 CCD 都在 Bayer RGGB [...]
设置自定义分辨率和帧率的方法是什么?更愚蠢的问题,有没有办法用这些 USB 相机控制快门时间?
编辑:我正在使用 Python。OpenCV 根本无法访问相机,但它可以与 Webcamoid 软件配合使用。
解决方案
我只是将您从相机采样的频率更改为您想要的帧速率。
如果我们看一下 MJPEG:
尺寸:离散 1280x720 间隔:离散 0.017s (60.000 fps)
只需每秒从该流中读取 20 次(基本上每第三帧获取一次),或每秒读取 18 次(每第三/第四帧获取一次)。
在 HTML 中,您可以使用 getUserMedia 执行此操作:
设置宽度、高度和帧率的变量:
var constraints = { audio: {sampleRate: audiobitrate,
echoCancellation: true},
video:{
width: { min: 100, ideal: width, max: 1920 },
height: { min: 100, ideal: height, max: 1080 },
frameRate: {ideal: framerate}
}
};
console.log(constraints);
navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
// do your thing... }
此代码来自我构建的直播应用程序(第 273 行):https ://github.com/dougsillars/browserLiveStream/blob/master/public/index.html
推荐阅读
- gradle - 为什么 Gradle 构建因 java11 和 jfreechart 依赖而失败?
- javascript - 使用 ASP.NET Web API 在 Angular 6 中下载文件
- python - 使用正则表达式或任何其他方法从电子邮件字符串中提取所有日期模式的最佳方法?
- java - Chrome 如何在可绘制对象中将文本添加到选项卡切换器?
- drone.io - 如何将 Drone 与自托管 git 存储库一起使用
- jquery - 为什么动画不适用于 IE 中的鼠标滚动但适用于平滑滚动
- selenium - 使用 chrome.tabCapture.capture 时“未找到请求的设备”
- python - IntegerField 上的烧瓶默认值
- angular - 创建 Angular 服务的 NPM 包的正确方法
- kotlin - 为什么在这种情况下不给我一个不可为空的整数