【问题标题】:USB webcam and available formatsUSB 网络摄像头和可用格式
【发布时间】:2021-02-20 04:44:42
【问题描述】:

我有一个 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 这样奇怪的东西。

This answer 说:

v4l2 仅支持列出的格式,其他任何内容都需要用户编码,而且很少提供 RGB,尽管几乎所有 CCD 都在 Bayer RGGB 中工作 [...]

设置自定义分辨率和帧率的方法是什么? 更傻的问题,有没有办法用这些 USB 相机控制快门时间?

编辑: 我正在使用 Python。 OpenCV 根本无法访问摄像头,但它与 Webcamoid 软件配合使用。

【问题讨论】:

    标签: opencv video camera usb codec


    【解决方案1】:

    我只想将您从相机采样的频率更改为您想要的帧速率。

    如果我们看一下 MJPEG:

    尺寸:离散 1280x720 间隔:离散 0.017s (60.000 fps)

    每秒从该流中读取 20 次(基本上每 3 帧获取一次),或每秒 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

    【讨论】:

      猜你喜欢
      • 2012-08-16
      • 1970-01-01
      • 1970-01-01
      • 2016-12-04
      • 1970-01-01
      • 2013-08-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-13
      相关资源
      最近更新 更多