Capturing multiple webcams (uvcvideo) with OpenCV on Linux

前端 未结 7 1193
时光取名叫无心
时光取名叫无心 2020-12-03 01:56

I am trying to simultaneously stream the images from 3 Logitech Webcam Pro 900 devices using OpenCV 2.1 on Ubuntu 11.10. The uvcvideo driver gets loaded for these.

C

7条回答
  •  温柔的废话
    2020-12-03 02:26

    I had this problem too and have a solution that lets me capture 2 cameras at 640x480 with mjpeg compression. I am using a Creative "Live Cam Sync HD VF0770" which incorrectly reports its bandwidth requirements. The quirks=128 fix works for 320x240 uncompressed video. But for compressed (mjpg) format the quirks=128 does not work (it does nothing for compressed formats).

    To fix this I modified the uvc driver as follows:

    download the kernel sources

    mkdir -p ~/Software/kernel-git
    cd ~/Software/kernel-git
    git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
    git checkout v3.2
    # NOTE: `uname -r`  shows me my current kernel is 3.2.0-60-generic
    # For a different kernel use a different tag
    

    copy uvc dir:

    mkdir -p ~/Software/uvcvideo_driver
    cd ~/Software/uvcvideo_driver
    #cp -a ~/Software/kernel-git/linux/drivers/media/usb/uvc .
    cp ~/Software/kernel-git/linux/drivers/media/video/uvc .
    

    modify Makefile

    cd ~/Software/uvcvideo_driver/uvc
    vi Makefile
    
            obj-m += aauvcvideo.o
            aauvcvideo-objs  := uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o \
                  uvc_status.o uvc_isight.o
            all:
              make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
    
            clean:
              make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
    

    Force bandwith to 0x400 when compressed.

    cd ~/Software/uvcvideo_driver/uvc
    vw uvc_video.c
    Find the uvc_fixup_video_ctrl() function.  At the end of the function add:
          if (format->flags & UVC_FMT_FLAG_COMPRESSED) {
            ctrl->dwMaxPayloadTransferSize = 0x400;
          }
    

    build the aauvcvideo module:

    make
    

    remove old module and insert new one:

    sudo rmmod uvcvideo
    sudo insmod ./aauvcvideo.ko quirks=128
    

    run gucview twice with compression in 2 different windows to test

    guvcview --device=/dev/video1 --format=mjpg --size=640x480
    guvcview --device=/dev/video2 --format=mjpg --size=640x480
    

    Good luck! -Acorn

提交回复
热议问题