Ask Your Question
0

I get no video from the camera that is connected with firewire.

asked 2015-12-01 05:10:28 -0600

MValeriy gravatar image

updated 2015-12-01 11:47:23 -0600

pklab gravatar image

I have a question. I get no video from the camera that is connected with firewire. ordinary web camera works properly

I work with opencv3.0.0 and VS12. there is no error, as if the program does not see the camera with VS10 and Opencv231 everything goes without problem

what could be the problem?

    #include "opencv2/opencv.hpp"

using namespace cv;

int main()
{
    int c;
    Mat img;
    VideoCapture cap(0);
    while (true)
    {
        cap >> img;
         if(img.empty()){
        continue;  }  //or break; 

        Mat edges;
        cvtColor(img, edges, CV_BGR2GRAY);

        Canny(edges, edges, 10, 100);
        imshow("Canny", edges); 
        imshow("Norm", img); 
        c=waitKey(1);

         if(c==27) 
         break;
    }
         return 0;
}
edit retag flag offensive close merge delete

Comments

use VideoCapture cap(CV_CAP_FIREWARE+deviceID); where deviceID=0 means default device.

pklab gravatar imagepklab ( 2015-12-01 05:31:19 -0600 )edit

VideoCapture cap (CV_CAP_FIREWARE + 0); VideoCapture cap (CV_CAP_FIREWIRE + 0); Does not help

MValeriy gravatar imageMValeriy ( 2015-12-01 06:22:54 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-12-01 11:41:24 -0600

pklab gravatar image

updated 2015-12-03 05:54:11 -0600

(Edit reassembling some comments)

I haven't a firewire cam to test but, to grab from them your OpenCV binaries should have IEEE1394 capturing support enabled. By default isn't (check HAVE_DC1394 in your /include/opencv2/cvconfig.h)

To enable IEEE1394 you should rebuild OpenCV enabling HAVE_DC1394 in CMAKE. This requires libdc1394 3rd party libs available on you PC. But it does not work for all cameras.

Is a common case for FireWire (or GigE IP) industrial cameras to have its own SDK/DLL for C++. In this case you have to create your own function that grabs using the SDK and write the image into a cv::Mat. Camera manufactures provide rich examples for free.

As alternative, if your firewire camera has a driver which provides a layer for Video For Windows (VFW) or DirectShow layer, you should be able to open it using standard VideoCapture cap(deviceID); where deviceID is the ID assigned to the cam. To know this ID is a bit difficult but you can search (if it exists) with a brute force using code as below.

have fun!

/** \brief Test all grabbing drivers and fills a vector of all available cameras CAPdrivers+ID
 * 
 * For each CAPdrivers+ID, opens the device. If success, push CAP+ID in \c camIdx
 * A grabbing test is done just to inform the user.
 * \param camIdx[out] a vector of all readable cameras CAP+ID
 * \note remove some cout to use as function
 */
bool EnumerateCameras(vector<int> &camIdx)
{
    camIdx.clear();
    struct CapDriver{
        int enumValue; string enumName; string comment;
    };
    // list of all CAP drivers (see highgui_c.h)
    vector<CapDriver> drivers;
    drivers.push_back({ CV_CAP_MIL, "CV_CAP_MIL", "MIL proprietary drivers" });
    drivers.push_back({ CV_CAP_VFW, "CV_CAP_VFW", "platform native" });
    drivers.push_back({ CV_CAP_FIREWARE, "CV_CAP_FIREWARE", "IEEE 1394 drivers" });
    drivers.push_back({ CV_CAP_STEREO, "CV_CAP_STEREO", "TYZX proprietary drivers" });
    drivers.push_back({ CV_CAP_QT, "CV_CAP_QT", "QuickTime" });
    drivers.push_back({ CV_CAP_UNICAP, "CV_CAP_UNICAP", "Unicap drivers" });
    drivers.push_back({ CV_CAP_DSHOW, "CV_CAP_DSHOW", "DirectShow (via videoInput)" });
    drivers.push_back({ CV_CAP_MSMF, "CV_CAP_MSMF", "Microsoft Media Foundation (via videoInput)" });
    drivers.push_back({ CV_CAP_PVAPI, "CV_CAP_PVAPI", "PvAPI, Prosilica GigE SDK" });
    drivers.push_back({ CV_CAP_OPENNI, "CV_CAP_OPENNI", "OpenNI (for Kinect)" });
    drivers.push_back({ CV_CAP_OPENNI_ASUS, "CV_CAP_OPENNI_ASUS", "OpenNI (for Asus Xtion)" });
    drivers.push_back({ CV_CAP_ANDROID, "CV_CAP_ANDROID", "Android" });
    drivers.push_back({ CV_CAP_ANDROID_BACK, "CV_CAP_ANDROID_BACK", "Android back camera" }),
    drivers.push_back({ CV_CAP_ANDROID_FRONT, "CV_CAP_ANDROID_FRONT","Android front camera"}),
    drivers.push_back({ CV_CAP_XIAPI, "CV_CAP_XIAPI", "XIMEA Camera API" });
    drivers.push_back({ CV_CAP_AVFOUNDATION, "CV_CAP_AVFOUNDATION", "AVFoundation framework for iOS" });
    drivers.push_back({ CV_CAP_GIGANETIX, "CV_CAP_GIGANETIX", "Smartek Giganetix GigEVisionSDK" });
    drivers.push_back({ CV_CAP_INTELPERC, "CV_CAP_INTELPERC", "Intel Perceptual Computing SDK" });

    std::string winName,driverName,driverComment;
    int driverEnum;
    Mat frame;
    bool found;
    std::cout << "Searching for cameras IDs..." << endl << endl;
    for (int drv = 0; drv < drivers.size(); drv++)
    {
        driverName = drivers[drv].enumName;
        driverEnum = drivers[drv].enumValue;
        driverComment = drivers[drv].comment;
        std::cout << "Testing driver " << driverName << "..." ;
        found = false;

        int maxID = 100; //100 IDs between drivers
        if (driverEnum == CV_CAP_VFW)
            maxID = 10; //VWF opens same camera after 10 ?!?
        else if (driverEnum == CV_CAP_ANDROID)
            maxID = 98; //98 and 99 are front and back cam
        else if ((driverEnum == CV_CAP_ANDROID_FRONT) || (driverEnum == CV_CAP_ANDROID_BACK))
            maxID = 1; 

        for (int idx = 0; idx <maxID; idx++)
        {
            VideoCapture cap(driverEnum + idx);  // open the camera
            if (cap.isOpened())                  // check if we ...
(more)
edit flag offensive delete link more

Comments

Hi. you were with HAVE_DC1394 right. I have changed, but unfortunately no pictures

MValeriy gravatar imageMValeriy ( 2015-12-02 00:58:08 -0600 )edit

I'm not sure about the alternative. How do I run this code? I created a new file and tried to run, but it did not work

MValeriy gravatar imageMValeriy ( 2015-12-02 01:05:14 -0600 )edit
1

Unfortunately it's not so easy. I didn't tested but, but to enable 1394 support in opencv you should:

  1. have 3rd party libdc1394 lib and your cam should be supported by the lib
  2. rebuild the opencv binaries. In CMAKE you have to enable "WITH_1394" flag and ensure that cmake can find libdc1394

As alternative

  • may be your camera its own library/DLL that you can use with C++. In this case in your OpenCV app you have to create a function that use this library and store grabbed image into a cv::Mat. This is a common way for many industrial cameras.
  • or, your camera has a driver that make the camera available via VFW or DSHOW. In this case you just need to know its deviceID... use my function to scan for deviceID
pklab gravatar imagepklab ( 2015-12-02 03:13:58 -0600 )edit

Like @pklab states, without rebuilding OpenCV you will not be able to run a firewire camera. Then add an extra cap property like he suggested in comments. And even then, it does not work for all cameras out there. It might be the case that you indeed need some camera specific interface.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-12-02 04:13:30 -0600 )edit

Hello, unfortunately I do not get along with your code. but I have found something of my camera. https://www.ptgrey.com/tan/10861 when I start FlyCapture2Test.cpp I get the following:

http://www.pictureshack.ru/images/423... and the examples I can not open, unfortunately, come error messages

MValeriy gravatar imageMValeriy ( 2015-12-03 03:50:29 -0600 )edit

but there is no deviceID

MValeriy gravatar imageMValeriy ( 2015-12-03 04:24:20 -0600 )edit

@MValeriy as you can read at the link: Point Grey recommends using FlyCapture 2 SDK to grab images and convert them to OpenCV images. Than get the SDK and use it with OpenCV as suggested... in addiction the application note provides Sample Code for OpenCV with "FlyCap2_to_MatImage.cpp".

You should get deviceID using my code if the cam has VFW or DSHOW interface... may be isn't your case.

pklab gravatar imagepklab ( 2015-12-03 05:24:45 -0600 )edit

I try to launch their code. It does not work.is the code complete? because the error is already in the first sentence

MValeriy gravatar imageMValeriy ( 2015-12-03 05:44:52 -0600 )edit

It does not work isn't a good starting point when asking support ;) Looking at "FlyCap2_to_MatImage.cpp" 1st statement is #include FlyCapture2.h. This file should be provided with the SDK and must be accessible within your project. Go on asking to Point Grey for more support on this. You could accept my answer if it helps.

pklab gravatar imagepklab ( 2015-12-03 08:39:39 -0600 )edit

Hello I have the same problem (communication Point Grey-OpenCV) in linux. The samples that you are mentioned above are designed for Windows and its quite complicated to run them in Linux.

I dont find any solution for this case, and Point Grey support are not able to help with linux (that is what they said).

Thanks!

Ludo gravatar imageLudo ( 2016-09-14 11:14:57 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-12-01 05:10:28 -0600

Seen: 14,832 times

Last updated: Dec 03 '15