问题描述
$ 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都在拜耳RGGB中工作。[...]
设置自定义分辨率和帧频的方式是什么? 更愚蠢的问题是,有没有办法控制这些USB相机的快门时间?
编辑: 我正在使用Python。 OpenCV与Webcamoid软件一起使用时,根本无法访问摄像机。
解决方法
我只是将您从摄像机采样的频率更改为所需的帧速率。
如果我们看一下MJPEG:
尺寸:离散1280x720 间隔:离散0.017s(60.000 fps)
只需从该流中每秒读取20次(基本上每3帧就读取一次),或每秒18次(每3/4帧就获取一次)即可。
在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