Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

My 2 camera's video capture program didn't work

I have used exactly the program suggested in my previous question and this is the that program:

int main()

{

cv::VideoCapture camera0(2);

cv::VideoCapture camera1(1);

if( !camera0.isOpened() ) return 1;

if( !camera1.isOpened() ) return 1;

int nbImage=0;

while(true) {

cv::Mat frame0;

camera0 >> frame0;

cv::Mat frame1;

camera1 >> frame1;

cv::imshow("Video0", frame0);

cv::imshow("Video1", frame1);

int c = cvWaitKey(40);

if ((static_cast<char>(c)=='s')

{

   imwrite(format("image0_%d.jpg",nbImage),frame0);

   imwrite(format("image1_%d.jpg",nbImage++),frame1);

}

if(27 == char(c)) break;

} I've runed this program and it had no error. But the console window just opened and I can't not capture my video because it didn't opened. I've using Basler twin cameras which has 3.0 USB cable, I've wonder if because of the bandwith of cable that the computer can not deal with 2 cameras at the same time or Gstreamer I've dowloaded didn't support 2 cameras? If i use the camera one by one it works. Do somebody have a solution for my problem? Thank you.

click to hide/show revision 2
None

updated 2019-11-07 11:29:21 -0600

berak gravatar image

My 2 camera's video capture program didn't work

I have used exactly the program suggested in my previous question and this is the that program:

int main()

{

main() { cv::VideoCapture camera0(2);

camera0(2); cv::VideoCapture camera1(1);

camera1(1); if( !camera0.isOpened() ) return 1;

1; if( !camera1.isOpened() ) return 1;

1; int nbImage=0;

nbImage=0; while(true) {

{
cv::Mat frame0;
 camera0 >> frame0;
 cv::Mat frame1;
 camera1 >> frame1;

cv::imshow("Video0", frame0);

frame0); cv::imshow("Video1", frame1);

frame1);
int c = cvWaitKey(40);
 if ((static_cast<char>(c)=='s')

{


{
 imwrite(format("image0_%d.jpg",nbImage),frame0);
 imwrite(format("image1_%d.jpg",nbImage++),frame1);

}


}
if(27 == char(c)) break;

}

} I've runed this program and it had no error. But the console window just opened and I can't not capture my video because it didn't opened. I've using Basler twin cameras which has 3.0 USB cable, I've wonder if because of the bandwith of cable that the computer can not deal with 2 cameras at the same time or Gstreamer I've dowloaded didn't support 2 cameras? If i use the camera one by one it works. Do somebody have a solution for my problem? Thank you.