Multiple video channels give same image? [closed]

asked 2016-10-23 09:23:17 -0600

ScaleSphere gravatar image

Hello community,

am working on a project involving realtime image processing of several consumer cameras on a normal computer. Since normal webcams can be problematic, I'm using an USB Video grabber with four channels: with PAL/NTSC camera modules.

Now I have the following code in OpenCV 3.1 to read all the video streams:

#include "stdafx.h"
#include <math.h>
#include "opencv2/opencv.hpp"

using namespace cv;
using namespace std;

int main(int, char**)
const String windows[] = { "Cam 0", "Cam 1", "Cam 2", "Cam 3" };

const int camera = 1; // Which camera to use
const int channelsOfCam = 4; // How many channels are uspposed to be available

VideoCapture capture = VideoCapture(camera); // Open the cam
if (!capture.isOpened()) // If not opened successfully
    return(0); // Quit

printf("Camera has been started.\n");

// Create and move the four windows into a rectangle
for (int ch = 0; ch < channelsOfCam; ch++)
    namedWindow(windows[ch], 1);
    moveWindow(windows[ch], 100 + ch*150, 100);

Mat chFrame[channelsOfCam];

for (;;) // Endless loop
    if (capture.isOpened())
        capture.grab(); // Grab the frame
        for (int ch = 0; ch < channelsOfCam; ch++)
            capture.retrieve(chFrame[ch], ch); // Retrieve the different channels
            imshow(windows[ch], chFrame[ch]); // Show in correct window

    // Perform screen update
    if (waitKey(1) >= 0) break;
return 0;

Despite using the "grab" and "retrieve" functions like described in the doc for "multi head cameras", the result is that I always get the input from the third physical channel (the cable has the number written on it) in all four image data-structures. No matter what I do, it never displays any of the other channels (have even tried returning to Opencv 2.3 where it cannot read any stream at all unfortunately).

Anyone having a suggestion what the cause could be? Do I have to use any of the camera parameters enable any of the other streams? Or can't the second argument of the retrieve function be used the way I did?

Huge thanks in advance!

Greetings, Alex

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-19 15:52:49.891463