how to capture video from webcam in MJPG opencv

自古美人都是妖i 提交于 2019-12-10 10:47:40

问题


I have bought the two of Genius facecam 1000x camera and trying to set up a stereo camera, the v4l2-ctl outputs for cameras are as follow :

ioctl: VIDIOC_ENUM_FMT
    Index       : 0
    Type        : Video Capture
    Pixel Format: 'YUYV'
    Name        : YUYV 4:2:2

    Index       : 1
    Type        : Video Capture
    Pixel Format: 'MJPG' (compressed)
    Name        : Motion-JPEG

As you can see the pixel format MJPG is supported and from this and this this pixel format is needed, but when I try to capture video from both webcams the VIDIOC_STREAMON: No space left on device error still happening for the second camera, I can only get stereo video at 320x240 resolution! I tried the following two but does not work for me :

  1. v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=1 
    
  2. Setting the FOURCC to MJPG causes the bellow error :

    HIGHGUI ERROR: V4L: Property <unknown property string>(6) not supported by device
    

    # setting the `FOURCC` will cause the 
    # `HIGHGUI ERROR: V4L: Property <unknown property string>(6) not supported by device`
    for p in ports:
        self.caps.append(cv2.VideoCapture(p))
        self.caps[-1].set(cv2.cv.CV_CAP_PROP_FOURCC('M','J','P','G'));
    

What should I do to get it right at relatively OK resolution?

P.S: All of my USB ports are connected to a single controller!

来源:https://stackoverflow.com/questions/40060515/how-to-capture-video-from-webcam-in-mjpg-opencv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!