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.
Leaving any potential camera problem aside, I think your use of waitkey is incorrect. Waitkey is the only way for the program to know for how long the image should be displayed after a imshow. So, I would try to place a waitkey after the first imshow and after the second one as well.
@urres_coding you're wrong, also using 2 waitKey calls is a terrible idea.
Note This function is the only method in HighGUI that can fetch and handle events, so it needs to be called periodically for normal event processing unless HighGUI is used within an environment that takes care of event processing.
Taken from the official documentation
@urres_coding I'll do this to see if what will be different