ViSP  2.7.0
vp1394CMUGrabber Class Reference

#include <vp1394CMUGrabber.h>

+ Inheritance diagram for vp1394CMUGrabber:

Public Types

enum  vpColorCodingType {
  YUV444, YUV422, YUV411, RGB8,
  MONO8, MONO16, UNKNOWN
}
 

Public Member Functions

 vp1394CMUGrabber ()
 
virtual ~vp1394CMUGrabber ()
 
void open (vpImage< unsigned char > &I)
 
void open (vpImage< vpRGBa > &I)
 
void acquire (vpImage< unsigned char > &I)
 
void acquire (vpImage< vpRGBa > &I)
 
void close ()
 
void displayCameraDescription (int cam_id)
 
void displayCameraModel ()
 
int getNumberOfConnectedCameras () const
 
vpColorCodingType getVideoColorCoding () const
 
void selectCamera (int cam_id)
 
void setControl (unsigned short gain, unsigned short shutter)
 
void setFramerate (unsigned long fps)
 
void setVideoMode (unsigned long format, unsigned long mode)
 
unsigned int getHeight () const
 
unsigned int getWidth () const
 

Public Attributes

bool init
 

Protected Attributes

unsigned int height
 
unsigned int width
 

Detailed Description

Firewire cameras video capture based on CMU 1394 Digital Camera SDK.

This block is based on the CMU 1394 Digital Camera SDK. The CMU 1394 Digital Camera Driver must be installed (go to http://www.cs.cmu.edu/~iwan/1394/index.html to download it).

  • Parameters:
    • Camera index (0, 1, 2, ... or 10). First camera has index 0.
    • Image format
    • Frame rate. Real frame rate depends on device capacities.
    • Control : shutter speed and gain can be internally set, but it is possible to set manually them. Exposure time register value. Real exposure time depends on device capacities. Gain register value. Real gain depends on device capacities.

The examples below show how to use this class.

Example 1:

#include <iostream>
#include <visp/vpConfig.h>
#include <visp/vpImage.h>
#include <visp/vpDisplayOpenCV.h>
#include <visp/vp1394CMUGrabber.h>
int main()
{
#if defined(VISP_HAVE_CMU1394)
std::cout << "ViSP Image acquisition example" <<std::endl;
g.open(I);
g.acquire(I);
for(;;)
{
g.acquire(I);
if (vpDisplay::getClick(I, false)) // a click to exit
break;
}
g.close();
#endif
std::cout << "ViSP exiting..." <<std::endl;
return 0;
}

Example 2:

#include <iostream>
#include <visp/vpConfig.h>
#include <visp/vpImage.h>
#include <visp/vpDisplayOpenCV.h>
#include <visp/vp1394CMUGrabber.h>
int main()
{
#if defined(VISP_HAVE_CMU1394)
std::cout << "ViSP Image acquisition example" << std::endl;
std::cout << "There are " << g.getNumberOfConnectedCameras() << " connected cameras." << std::endl;
std::cout << "There is " << g.getNumberOfConnectedCameras() << " connected camera." << std::endl;
else
std::cout << "There is no connected camera." << std::endl;
// Setting camera parameters manually
g.setControl(0, 2000);
g.setFramerate(3); // 15 FPS
g.setVideoMode(0, 5); // 640x480 - MONO
g.open(I);
g.acquire(I);
// Display camera description
std::cout << "Height: " << g.getHeight() << " Width: " << g.getWidth() << std::endl;
for(;;)
{
g.acquire(I);
if (vpDisplay::getClick(I, false)) // a click to exit
break;
}
g.close();
#endif
std::cout << "ViSP exiting..." <<std::endl;
return 0;
}
Examples:
grab1394CMU.cpp, servoPioneerPanSegment3D.cpp, servoPioneerPoint2DDepth.cpp, and servoPioneerPoint2DDepthWithoutVpServo.cpp.

Definition at line 182 of file vp1394CMUGrabber.h.

Member Enumeration Documentation

Enumeration of color codings.

Enumerator
YUV444 
YUV422 
YUV411 
RGB8 
MONO8 
MONO16 
UNKNOWN 

Definition at line 188 of file vp1394CMUGrabber.h.

Constructor & Destructor Documentation

vp1394CMUGrabber::vp1394CMUGrabber ( )

Basic constructor.

Definition at line 57 of file vp1394CMUGrabber.cpp.

References vpFrameGrabber::height, vpFrameGrabber::init, and vpFrameGrabber::width.

vp1394CMUGrabber::~vp1394CMUGrabber ( )
virtual

Destructor.

Definition at line 76 of file vp1394CMUGrabber.cpp.

References close().

Member Function Documentation

void vp1394CMUGrabber::acquire ( vpImage< unsigned char > &  I)
virtual
void vp1394CMUGrabber::acquire ( vpImage< vpRGBa > &  I)
virtual

Grabs a color image from the selected camera. Since the cameras are not able to grab RGBa color coding format, the acquired image is converted in a RGBa to match the requested format. This transformation could be time consuming.

Parameters
I: Acquired color image in RGBa format.

Implements vpFrameGrabber.

Definition at line 392 of file vp1394CMUGrabber.cpp.

References vpImage< Type >::bitmap, close(), vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpImageConvert::GreyToRGBa(), vpFrameGrabber::init, vpFrameGrabberException::initializationError, MONO16, vpImageConvert::MONO16ToRGBa(), MONO8, vpFrameGrabberException::otherError, RGB8, vpImageConvert::RGBToRGBa(), vpERROR_TRACE, YUV411, vpImageConvert::YUV411ToRGBa(), YUV422, vpImageConvert::YUV422ToRGBa(), YUV444, and vpImageConvert::YUV444ToRGBa().

void vp1394CMUGrabber::close ( )
virtual

Stop the acquisition of images and free the camera.

Implements vpFrameGrabber.

Definition at line 450 of file vp1394CMUGrabber.cpp.

References vpFrameGrabber::init, and vpFrameGrabberException::otherError.

Referenced by acquire(), open(), selectCamera(), and ~vp1394CMUGrabber().

void vp1394CMUGrabber::displayCameraDescription ( int  cam_id)

Display information about the camera on the standard output.

Definition at line 553 of file vp1394CMUGrabber.cpp.

void vp1394CMUGrabber::displayCameraModel ( )

Display camera model on the standard output. Call it after open the grabber.

Definition at line 574 of file vp1394CMUGrabber.cpp.

unsigned int vpFrameGrabber::getHeight ( ) const
inlineinherited

Return the number of rows in the image.

Examples:
AROgre.cpp, AROgreBasic.cpp, HelloWorldOgre.cpp, and HelloWorldOgreAdvanced.cpp.

Definition at line 119 of file vpFrameGrabber.h.

Referenced by vp1394Grabber::acquire(), and vp1394Grabber::open().

int vp1394CMUGrabber::getNumberOfConnectedCameras ( ) const

Get the number of connected cameras.

Definition at line 531 of file vp1394CMUGrabber.cpp.

vpColorCodingType vp1394CMUGrabber::getVideoColorCoding ( ) const
inline

Get the video color coding format.

Definition at line 250 of file vp1394CMUGrabber.h.

References MONO16, MONO8, RGB8, UNKNOWN, YUV411, YUV422, and YUV444.

unsigned int vpFrameGrabber::getWidth ( ) const
inlineinherited

Return the number of columns in the image.

Examples:
AROgre.cpp, AROgreBasic.cpp, HelloWorldOgre.cpp, and HelloWorldOgreAdvanced.cpp.

Definition at line 121 of file vpFrameGrabber.h.

Referenced by vp1394Grabber::acquire(), and vp1394Grabber::open().

void vp1394CMUGrabber::open ( vpImage< unsigned char > &  I)
virtual

Initialization of the grabber using a greyscale image.

Parameters
I: gray level image.

Implements vpFrameGrabber.

Examples:
grab1394CMU.cpp, servoPioneerPanSegment3D.cpp, servoPioneerPoint2DDepth.cpp, and servoPioneerPoint2DDepthWithoutVpServo.cpp.

Definition at line 280 of file vp1394CMUGrabber.cpp.

References close(), vpImage< Type >::init(), vpFrameGrabberException::otherError, and vpERROR_TRACE.

void vp1394CMUGrabber::open ( vpImage< vpRGBa > &  I)
virtual

Initialization of the grabber using a color image.

Parameters
I: color image.

Implements vpFrameGrabber.

Definition at line 300 of file vp1394CMUGrabber.cpp.

References close(), vpImage< Type >::init(), vpFrameGrabberException::otherError, and vpERROR_TRACE.

void vp1394CMUGrabber::selectCamera ( int  cam_id)

Select the camera on the bus from its index. The first camera found on the bus has index 0.

Parameters
cam_id: Camera index.

Definition at line 89 of file vp1394CMUGrabber.cpp.

References close(), vpFrameGrabberException::initializationError, and vpERROR_TRACE.

void vp1394CMUGrabber::setControl ( unsigned short  gain,
unsigned short  shutter 
)

Set the gain and the shutter values. This method has to be called before open().

Definition at line 469 of file vp1394CMUGrabber.cpp.

void vp1394CMUGrabber::setFramerate ( unsigned long  fps)

Set camera framerate rate. This method has to be called before open().

Parameters
fps: Value form 0 to 7 used to select a specific camera framerate. See the following table for the correspondances between the input value and the framerate.
Value Frame rate
0 1.875 fps
1 3.75 fps
2 7.5 fps
3 15 fps
4 30 fps
5 60 fps
6 120 fps
7 240 fps
Examples:
servoPioneerPanSegment3D.cpp, servoPioneerPoint2DDepth.cpp, and servoPioneerPoint2DDepthWithoutVpServo.cpp.

Definition at line 658 of file vp1394CMUGrabber.cpp.

void vp1394CMUGrabber::setVideoMode ( unsigned long  format,
unsigned long  mode 
)

Set the camera format and video mode. This method has to be called before open().

Parameters
format: Camera video format.
mode: Camera video mode.

See the following table for the correspondances between the input format and mode and the resulting video color coding.

Format Mode (H) x (W) Color
0 0 160 x 120 YUV444
0 1 320 x 240 YUV422
0 2 640 x 480 YUV411
0 3 640 x 480 YUV422
0 4 640 x 480 RGB8
0 5 640 x 480 MONO8
0 6 640 x 480 MONO16
1 0 800 x 600 YUV422
1 1 800 x 600 RGB8
1 2 800 x 600 MONO8
1 3 1024 x 768 YUV422
1 4 1024 x 768 RGB8
1 5 1024 x 768 MONO8
1 6 800 x 600 MONO16
1 7 1024 x 768 MONO16
2 0 1280 x 960 YUV422
2 1 1280 x 960 RGB8
2 2 1280 x 960 MONO8
2 3 1600 x 1200YUV422
2 4 1600 x 1200RGB8
2 5 1600 x 1200MONO8
2 6 1280 x 960 MONO16
2 7 1600 x 1200MONO16
Examples:
servoPioneerPanSegment3D.cpp, servoPioneerPoint2DDepth.cpp, and servoPioneerPoint2DDepthWithoutVpServo.cpp.

Definition at line 631 of file vp1394CMUGrabber.cpp.

Member Data Documentation