Ask Your Question
2

VideoCapture open() won't open second camera

asked 2013-08-26 16:19:32 -0600

BBro gravatar image

updated 2013-08-27 02:08:08 -0600

I am trying to use stereo cameras. I have two logitech c525s. The first camera opens fine and displays images but when I use the VideoCapture.open() command to open the second camera, the program hangs. I can access each camera individually.

I am using Windows 7, Visual Studio 2010 and C++ Windows device manager sees both cameras individually.

Is there something I am missing or neglecting to do?

edit retag flag offensive close merge delete

Comments

Just a small remark. In the future, try using the tags without the hashtags supplied. It creates tons of doubles and makes effective searching through this forum quite hard. Thank you in advance!

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-27 02:08:39 -0600 )edit

Pls. post relevant code. It helps.

SpiderGears gravatar imageSpiderGears ( 2014-02-06 18:08:14 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2013-08-26 16:26:04 -0600

berak gravatar image

updated 2013-08-26 16:30:25 -0600

sounds like you're trying to open both captures on the same device id(-1, the default), instead try :

VideoCapture cap0(0);
VideoCapture cap1(1);

// later: 
while( cap0.isOpened() && cap1.isOpened() ) {
    Mat frame0;    cap0.read( frame0 );
    Mat frame1;    cap1.read( frame1 );
    // stereo processing here
}

again, all i'm saying is: 2 cams need 2 seperate id's

edit flag offensive delete link more

Comments

I have been using separate device id's. I tried your code, but still the same problem unfortunately. cap0 opens, but cap1 doesn't.

BBro gravatar imageBBro ( 2013-08-26 17:00:18 -0600 )edit
1

Are this USB camera's? It is possible that your hardware USB bus cannot power two camera's at the same time. If it are ethernet camera's then it is possible they have the same ip configuration in your network?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-27 02:11:58 -0600 )edit
1

Was just debugging the same problem (but with Logitech C270's), and @StevenPuttemans comment was the solution. When both cameras were powered from the same USB hub, I saw the hang. The problem disappeared when they were powered separately.

tsellon gravatar imagetsellon ( 2014-05-08 13:22:07 -0600 )edit

Yep same problem here, you need seperate USB busses in order to address two cameras at same time. Else they are interleaved but thats not interesting for software purposes.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-05-09 01:59:15 -0600 )edit
0

answered 2013-08-27 01:48:37 -0600

engine gravatar image

updated 2013-08-27 02:10:01 -0600

Hi! having two video input devices doesn't mean automatically that their IDs are 0 and 1, did you try to access the second camera alone with the ID 1 ? I have two cameras and here what I've tried and it worked :

int main (){

cv::VideoCapture cap(0), cap2(2);
int key = 0;
cv::Mat frame,frame1;

while(key != 27){
    cap2 >> frame1;
    cap >> frame;
    cv::imshow("0",frame);
    cv::imshow("1", frame1);
    key = cv::waitKey(10);

}
cap.release();
cap2.release();
return 0;
}
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-08-26 16:19:32 -0600

Seen: 17,077 times

Last updated: Feb 06 '14