OpenCV & the CMU1394 camera driver

The integration of a firewire camera that works with the CMU1394 camera driver is quite simple by using its API and you can avoid using DirectX. Download the driver at CMU 1394 driver and install it. Take a look at the C/C++ example below. It's pretty much self explaining. Used diver version is 6.4.4.

Example

#include "1394Camera.h"

// adjust parameters to your needs
#define CAM_RES_WIDTH 640
#define CAM_RES_HEIGHT 480
#define CAM_RES_CHANNELS 3

//camera object of the 1394CMU driver
C1394Camera Camera;


int main( int argc, char** argv )
{
        // several checks if camera is connected and can be initialized as well as setting
        // of camera properties and starting of image aquisition
        if(Camera.CheckLink() != CAM_SUCCESS)
        {
                printf("\nNo Link.");
                return -1;
        }
        if(Camera.InitCamera() != CAM_SUCCESS)
        {
                printf("\nInitialization failed.");
                return -1;
        }
        if(Camera.SetVideoFormat(0) != CAM_SUCCESS)
        {
                printf("\nCould not set video format.");
                return -1;
        }
        if(Camera.SetVideoMode(5) != CAM_SUCCESS)
        {
                printf("\nCould not set video mode.");
                return -1;
        }
        if(Camera.SetVideoFrameRate(4) != CAM_SUCCESS)
        {
                printf("\nCould not set frame rate.");
                return -1;
        }
        if(Camera.StartImageAcquisition() != CAM_SUCCESS)
        {
                printf("\nCould not start image acquisation.");
                return -1;
        }
        
      //give camera a chance to inititalize and adjust before starting frame aquisition
        cvWaitKey(1000); 
        
        cvNamedWindow( "Source",1);     
        
        IplImage *Image = cvCreateImage( cvSize(CAM_RES_WIDTH, CAM_RES_HEIGHT), 8, CAM_RES_CHANNELS);
                        
      //aquire frame from camera
        if(Camera.AcquireImage() != CAM_SUCCESS)
        {       
                printf("\nCould not acquire image.");
                return 1;
        }
        
      //read frame from internal CMU1394 storage to buffer
        Camera01.getRGB((unsigned char*)(Image->imageData), (CAM_RES_WIDTH*CAM_RES_HEIGHT*3));
                        
        cvShowImage("Source", Image);
        cvWaitKey(0);
        
        Camera.StopImageCapture();
        cvReleaseImage(&Image);
        cvDestroyWindow("Source");
}

OpenCVAnd1304CMU (last edited 2008-05-28 14:02:31 by localhost)

SourceForge.net Logo