libv4l2错误:设备上没有剩余空间

时间:2014-12-05 18:53:06

标签: c++ opencv camera runtime-error

我有两个不同的相机。我使用下面的简单代码,我得到一个错误。在这个网站上有一个类似的问题,但没有一个接受的答案。错误消息是:

libv4l2: error turning on stream: No space left on device
VIDIOC_STREAMON: No space left on device
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file 
/home/OpenCV/opencv-2.4.10/modules/highgui/src/window.cpp, line 269

代码:

VideoCapture cap(2); 
VideoCapture cap2(1); 

if(!cap.isOpened())  // check if we succeeded
{
    cout << "Webcam cannot open!\n" ;
    return -1;
}
if(!cap2.isOpened())  // check if we succeeded
{
    cout << "Webcam2 cannot open!\n" ;
    return -1;
}
namedWindow( "Window1", CV_WINDOW_AUTOSIZE );
namedWindow( "Window2", CV_WINDOW_AUTOSIZE );
for(;;)
{
    iKey = waitKey(5);
    if (iKey == ESC) {  break;  }
    cap >> frame;
    cap2 >> frame2;

    imshow("Window1", frame);
    imshow("Window2", frame2);
}

编辑1 根据我在网上的搜索,这些相机使用相同的集线器。我对此进行了测试,输出如下。我不明白我应该怎么做才能解决这个问题。

sudo cat /sys/kernel/debug/usb/devices | grep "B: "

B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
B:  Alloc= 37/900 us ( 4%), #Int=  2, #Iso=  0
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0 
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0

2 个答案:

答案 0 :(得分:1)

我在两个彼此相邻的USB端口上使用两个深度感相机(USB)时遇到了同样的问题。他们在里面使用了相同的usb总线并且太多了,所以我将其切换到我的usb 3.0端口(这是另一个总线),现在它可以工作。

答案 1 :(得分:0)

如果你得到低分辨率的帧,问题就会解决。下面的代码对我来说已经足够了。

VideoCapture cap1 = VideoCapture(1);
VideoCapture cap2 = VideoCapture(2);

cap1.set(CV_CAP_PROP_FRAME_WIDTH, 300);
cap1.set(CV_CAP_PROP_FRAME_HEIGHT, 300);
cap2.set(CV_CAP_PROP_FRAME_WIDTH, 300);
cap2.set(CV_CAP_PROP_FRAME_HEIGHT, 300);
相关问题