【问题标题】:VideoCapture fails with camera in USB 3.0 portVideoCapture 因 USB 3.0 端口中的摄像头而失败
【发布时间】:2014-03-14 15:42:14
【问题描述】:

为什么当我的相机连接到 USB 2.0 端口时,以下代码可以工作,但当相机连接到 USB 3.0 端口时,我收到“无相机”错误?我在 Ubuntu 12.04 LTE 32 位上运行 OpenCV 2.4。我也看到了other cameras and drivers 的这个问题,所以我怀疑这可能是 Linux 的问题

#include <stdio.h>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"

using namespace cv;

int main(){

    Mat img;
    int imgw = 640;
    int imgh = 480;

    VideoCapture cap(0); // open the default camera
    if(!cap.isOpened()){ // check if we succeeded
        printf("No camera\n");
        return -1;
    }
    cap.set(CV_CAP_PROP_FRAME_WIDTH,  imgw);
    cap.set(CV_CAP_PROP_FRAME_HEIGHT, imgh);

    namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );

    for( ; ; ){

        cap.read( img );

        imshow( "Display Image", img );

        if( waitKey( 5 ) == 27 ) break;

    }

    return 0;

};

编辑: 通过连接到 USB 3.0 端口的 USB 2.0 集线器也会引发错误。

编辑 2: 实际上,此代码在重新启动后工作一次。之后,相机不再出现在 /dev 中,也不再出现在 lsusb 的输出中。运行一次上述程序后,该卡上的 USB 3.0 端口均无法工作。

【问题讨论】:

  • 运行 ls /dev 并确保 video0 在那里。
  • @Haris 见上面的编辑 2

标签: opencv usb ubuntu-12.04


【解决方案1】:

问题似乎取决于计算机,或者更具体地说,可能取决于 USB 卡。我已经在另外两台电脑上试过了,效果很好。

所以一个解决方案:尝试另一台计算机。

【讨论】:

    猜你喜欢
    • 2019-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-05
    • 1970-01-01
    • 2015-03-01
    • 1970-01-01
    • 2012-04-17
    相关资源
    最近更新 更多