Search code examples
opencvv4l2v4l

OpenCV is able to change to composite input?


I would like to know if OpenCV is able to set the camera (dev/video1) to composite or S-video input.

The camera I was using only runs in composite input, but v4l2 opens dev/video1 in S-Video input by default. V4l2 is able to change from S-video to composite input by QT V4l2 utils application.

The opencv is using v4l to capture imagens from camera, and I want to change to composite input in code using OpenCV. Is that possible? If it's not, what is the solution to this?

Thanks in advance.


Solution

  • You have just to change the input with "v4l2-ctl" ! For example, I use Python on my raspberry to capture the video stream from S-Video with OpenCV :

        import cv, os
    
        print "Initializing video capture from /dev/video0 ..."
        capture = cv.CaptureFromCAM(0)
        cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FRAME_WIDTH, 720)
        cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FRAME_HEIGHT, 576)
    
        print "Configuring video capture (V4L2) ..."
        os.system("v4l2-ctl -d /dev/video0 -i 5 -s 4 --set-fmt-video=width=720,height=576,pixelformat=4")
    

    With :

    • -d : device (in my case /dev/video0),
    • -i : input. for my Easycap (0 = CVBS0; 1 = CVBS1; 2 = CVBS2; 3 = CVBS3; 4 = CVBS4; 5 = S-VIDEO)
    • -s : norm (0 = PAL_BGHIN; 1 = NTSC_N_443; 2 = PAL_Nc; 3 = NTSC_N; 4 = SECAM; 5 = NTSC_M; 6 = NTSC_M_JP; 7 = PAL_60; 8 = NTSC_443; 9 = PAL_M;)