0
votes

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

    #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.

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

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

Does this mean the camera is not recognized?

2
unrelated, but please never use an absolute path in includes, also do not use the outdated opencv c-api headers, but "opencv2/highgui/highgui.hpp"berak
VideoCapture cap(0); means default cam,VideoCapture cap(1); should be another cam, is this woork?Kosovan
@berak thank you. What do you mean by unrelated?Lakshmi Narayanan
Do you see it in your OS? If yes, then the error is not because it is not recognized. Anyway, have you seen this? So try the both cap1(0) and cap2(1), and check both if they are open.sop
This one is also linked to your problem, try them, see if you can access the both cameras.sop

2 Answers

1
votes

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

  • unplug camera and wait few seconds;
  • open terminal and digit:
    • watch dmesg
    • lspci | grep -E -i "(1394|firewire)" #this could give you something
  • 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
0
votes

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.

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