dimanche 27 avril 2014

c ++ - capture de flux vidéo à partir de deux webcams se fige au bout de quelques secondes - Stack Overflow


I am using OpenCV 2.4.5 to capture an image feed from two Logitech c905 webcams on Ubuntu 12.04. When using one camera everything works fine but when i switch to capturing two camera's simultaneously the capture freezes after about 10 seconds. I get an error that says select timeout


My code is summarized as follows:


    VideoCapture capture1 = VideoCapture( 0 );
VideoCapture capture2 = VideoCapture( 2 );
if(!capture1.isOpened()) {cout << "Cannot find device1!\n";}
if(!capture2.isOpened()) {cout << "Cannot find device2!\n";}
namedWindow("videol",CV_WINDOW_KEEPRATIO);
namedWindow("videor",CV_WINDOW_KEEPRATIO);
moveWindow("videol",10,10);
moveWindow("videor",10,10);

for(;;){
capture1.grab();
capture2.grab();
capture2.retrieve(imgl_distorted);
capture1.retrieve(imgr_distorted);
imshow("videol",imgl);
imshow("videor",imgr);
key = cvWaitKey(30);
//Quit the program if the user presses "esc"
if(key == 27){ break; }
}

I tried the solutions proposed in Select Timeout error in Ubuntu - Opencv and on OpenCV 2.4.3 video capture returns error of "select timeout". But neither worked. I am using two different two different usb busses. As shown by my output from lsusb | grep Webcam:


    Bus 003 Device 002: ID 046d:080a Logitech, Inc. Portable Webcam C905
Bus 002 Device 004: ID 046d:080a Logitech, Inc. Portable Webcam C905

Update: I did not change anything to my knowing but know I can not get one of the two cameras to work. when I open guvcview I can get one cam to work fluently but when switching to my second camera (while not having the first running) it crashes (sometimes immediately and sometimes after about 0-2 seconds). I get the following error:



Could not grab image (select timeout): Resource temporarily unavailable



When running dmesg i get a bunch of the following errors:



xhci_hcd 0000:04:00.0: ERROR Transfer event TRB DMA ptr not part of current TD



PS I also get the following warning: "VIDIOC_QUERYMENU: Invalid argument" when running the c++ code



I am using OpenCV 2.4.5 to capture an image feed from two Logitech c905 webcams on Ubuntu 12.04. When using one camera everything works fine but when i switch to capturing two camera's simultaneously the capture freezes after about 10 seconds. I get an error that says select timeout


My code is summarized as follows:


    VideoCapture capture1 = VideoCapture( 0 );
VideoCapture capture2 = VideoCapture( 2 );
if(!capture1.isOpened()) {cout << "Cannot find device1!\n";}
if(!capture2.isOpened()) {cout << "Cannot find device2!\n";}
namedWindow("videol",CV_WINDOW_KEEPRATIO);
namedWindow("videor",CV_WINDOW_KEEPRATIO);
moveWindow("videol",10,10);
moveWindow("videor",10,10);

for(;;){
capture1.grab();
capture2.grab();
capture2.retrieve(imgl_distorted);
capture1.retrieve(imgr_distorted);
imshow("videol",imgl);
imshow("videor",imgr);
key = cvWaitKey(30);
//Quit the program if the user presses "esc"
if(key == 27){ break; }
}

I tried the solutions proposed in Select Timeout error in Ubuntu - Opencv and on OpenCV 2.4.3 video capture returns error of "select timeout". But neither worked. I am using two different two different usb busses. As shown by my output from lsusb | grep Webcam:


    Bus 003 Device 002: ID 046d:080a Logitech, Inc. Portable Webcam C905
Bus 002 Device 004: ID 046d:080a Logitech, Inc. Portable Webcam C905

Update: I did not change anything to my knowing but know I can not get one of the two cameras to work. when I open guvcview I can get one cam to work fluently but when switching to my second camera (while not having the first running) it crashes (sometimes immediately and sometimes after about 0-2 seconds). I get the following error:



Could not grab image (select timeout): Resource temporarily unavailable



When running dmesg i get a bunch of the following errors:



xhci_hcd 0000:04:00.0: ERROR Transfer event TRB DMA ptr not part of current TD



PS I also get the following warning: "VIDIOC_QUERYMENU: Invalid argument" when running the c++ code


Related Posts:

0 commentaires:

Enregistrer un commentaire