Ask Your Question

PN's profile - activity

2014-02-06 05:37:19 -0600 answered a question VideoCapture open() won't open second camera

Hi,

I also have problem turning on the second camera. Even with a simple code similar to the one given above. I just want to avoid asking the question in a new thread.

include "opencv\cv.h"

include "highgui.h"

int main (){

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

while( cap.isOpened() && cap2.isOpened() ){

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

} cap.release(); cap2.release(); return 0; }

The issue seems to be related to the presence of the second camera. When only one camera is connected, 2 windows are opened. The second window is all black as it is not present.

When both are present and active then, I got this message error:

The thread 'Win64 Thread' (0xe9c) has exited with code 0 (0x0). The thread 'Win64 Thread' (0x17bc) has exited with code 0 (0x0). The thread 'Win64 Thread' (0xf14) has exited with code 0 (0x0). The thread 'Win64 Thread' (0x153c) has exited with code 0 (0x0). The thread 'Win64 Thread' (0x77c) has exited with code 0 (0x0). The thread 'Win64 Thread' (0x5f8) has exited with code 0 (0x0). The thread 'Win64 Thread' (0x168c) has exited with code 0 (0x0). The thread 'Win64 Thread' (0x159c) has exited with code 0 (0x0). The thread 'Win64 Thread' (0x524) has exited with code 0 (0x0).

It seems to me that the sw is trying to open the same camera twice as I can see the same camera blinking twice even though there are 2 different ids for them. Also if internal camera is used then no window is shown. It just exited.

If you have good suggestion, please let know. I'm using VS2010 on Windows7 64bits.