Opencv没有检测linux上的火线网络摄像头

时间:2022-08-01 21:19:59

I have connected a cam through firewire and tried to access it using opencv. The camera is detected in coriander and able to get a video stream. Below is the code I used

我已经通过火线连接了一个凸轮,并试图使用opencv访问它。相机在芫荽中被检测到,并能得到一个视频流。下面是我使用的代码

    #include "/home/iiith/opencv-2.4.9/include/opencv/cv.h"
    #include "/home/iiith/opencv-2.4.9/include/opencv/highgui.h"
    #include "cxcore.h"
    #include <iostream>

    using namespace cv;
    using namespace std;

    int main(int,char**)
    {
        VideoCapture cap(0);
        if(!cap.isOpened())
            cout<<"Camera not detected"<<endl;
        while(1)
        {
            Mat frame;
            namedWindow("display",1);
            cap >> frame;
            imshow("display",frame);
            waitKey(0); 
        }
    }

When I run this code, the video is streamed from the webcam instead of my firewire cam. I tried the same code in my friend's system and there the firewire cam was detected. I tested the settings using different commands such as testlibraw , lsmod and they are all the same. Even the Opencv version, 2.4.9, Ubuntu 12.04 are all the same. This is really bizarre and am at this for 2 days. Can anyone please tell me what the difference could be? How can I get the external cam detected in opencv? Thanks in advance.

当我运行这段代码时,视频是通过网络摄像头而不是我的火线摄像头。我在我朋友的系统中尝试了同样的代码,结果发现了火线摄像头。我使用不同的命令测试了这些设置,比如testlibraw, lsmod,它们都是一样的。即使是Opencv版本,2.4.9,Ubuntu 12.04也是一样的。这真的很奇怪,我在这呆了两天。谁能告诉我有什么不同吗?如何在opencv中检测到外部凸轮?提前谢谢。

Note : Does this have something to have with setting the default cam? Thanks.

注意:设置默认的cam有什么用吗?谢谢。

Update 1 : VideoCapture cap(1) gives the following error HIGHGUI ERROR: V4L: index 1 is not correct!

更新1:VideoCapture cap(1)给出了以下错误HIGHGUI错误:V4L: index 1不正确!

Does this mean the camera is not recognized?

这是否意味着摄像头无法识别?

2 个解决方案

#1


1  

First, you should be sure that camera is recognized from your s.o.

首先,你应该确保相机是从你的s.o识别出来的。

  • unplug camera and wait few seconds;
  • 拔掉相机插头,等待几秒钟;
  • open terminal and digit:
    • watch dmesg
    • 看dmesg
    • lspci | grep -E -i "(1394|firewire)" #this could give you something
    • lspci | grep -E -i“(1394|firewire)”这可以给你一些东西
  • 开放终端和数字:观看dmesg lspci | grep -E -i“(1394|firewire)”这可以给你一些东西
  • plug your device and read new entry on terminal
  • 插入设备并在终端上读取新条目
  • if your device is recognized you can launch a command like this:
    • mplayer tv:// -tv driver=v4l2:width=352:height=288
    • 电视媒体播放器:/ /独立电视司机= v4l2:宽度= 352:高度= 288
  • 如果您的设备被识别,您可以启动如下命令:mplayer tv:// -tv驱动程序=v4l2:width=352:height=288

#2


0  

The Possible problem could be that the camera connected through firewire is not recognized by the system.

可能的问题是,通过火线连接的摄像机不被系统识别。

First try to see the camera output using AMcap or some other webcam software and check if you are able to see this.

首先尝试使用AMcap或其他网络摄像头软件查看相机输出,并检查您是否能够看到这个。

If you not able to see the video in amcap then it means that drivers of that particular camera is missing.

如果你不能在amcap中看到视频,那就意味着那个特定相机的驱动程序丢失了。

#1


1  

First, you should be sure that camera is recognized from your s.o.

首先,你应该确保相机是从你的s.o识别出来的。

  • unplug camera and wait few seconds;
  • 拔掉相机插头,等待几秒钟;
  • open terminal and digit:
    • watch dmesg
    • 看dmesg
    • lspci | grep -E -i "(1394|firewire)" #this could give you something
    • lspci | grep -E -i“(1394|firewire)”这可以给你一些东西
  • 开放终端和数字:观看dmesg lspci | grep -E -i“(1394|firewire)”这可以给你一些东西
  • plug your device and read new entry on terminal
  • 插入设备并在终端上读取新条目
  • if your device is recognized you can launch a command like this:
    • mplayer tv:// -tv driver=v4l2:width=352:height=288
    • 电视媒体播放器:/ /独立电视司机= v4l2:宽度= 352:高度= 288
  • 如果您的设备被识别,您可以启动如下命令:mplayer tv:// -tv驱动程序=v4l2:width=352:height=288

#2


0  

The Possible problem could be that the camera connected through firewire is not recognized by the system.

可能的问题是,通过火线连接的摄像机不被系统识别。

First try to see the camera output using AMcap or some other webcam software and check if you are able to see this.

首先尝试使用AMcap或其他网络摄像头软件查看相机输出,并检查您是否能够看到这个。

If you not able to see the video in amcap then it means that drivers of that particular camera is missing.

如果你不能在amcap中看到视频,那就意味着那个特定相机的驱动程序丢失了。