Capturing through a single multi-head (stereo) camera using OpenCV

asked 2014-04-06 01:56:02 -0600

BS gravatar image

I have a single multi-head (stereo) usb camera that can be detected and can stream stereo videos using the "Video Capture Sources" filter in GraphEdit Multi-Head Camera.

I'm trying to access both channels using OpenCV2.4.8 (on PC that has VS2010, Win7 X64) for further stereo image processing. However, I can only detect/stream single head(channel) of the camera and not both stereo heads of it. My code is set according to the related documentation notes of VideoCapture::grab/VideoCapture::retrieve and looks like the following:

#include "opencv2/opencv.hpp"
using namespace cv;
int main(int, char**)
{
    VideoCapture cap(0); // open the default camera
    if(!cap.isOpened())  // check if we succeeded
        return -1;
    Mat Lframe,Rframe;
    namedWindow("Lframe",CV_WINDOW_AUTOSIZE);namedWindow("Rframe",CV_WINDOW_AUTOSIZE);
    while(char(waitKey(1)) != 'q') {
        if(cap.grab())
            cap.retrieve(Lframe,0); cap.retrieve(Rframe,1);// get a new frame
        imshow("Lframe",Lframe);imshow("Rframe",Rframe);
        if(waitKey(30) >= 0) break;
    }
    return 0;
}

The problem is that the rendered channels (Lframe,Rframe) are identical no matter which Channel index is passed. Hence, only certain head is accessed & I can't get stereo streaming.

Is there a way to use "Video Capture Sources" filter directly with OpenCV?

Waiting for your assistance & Thank you in advance,

edit retag flag offensive close merge delete