IEEE1394grabber Class Reference

Definition and access functions for FireWire digital camera frame capture. More...

#include <Devices/IEEE1394grabber.H>

Inheritance diagram for IEEE1394grabber:
Inheritance graph
[legend]
Collaboration diagram for IEEE1394grabber:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 IEEE1394grabber (OptionManager &mgr, const std::string &descrName="IEEE1394 Frame Grabber Driver", const std::string &tagName="IEEE1394FrameGrabber", const ParamFlag flags=USE_MY_VAL)
 Constructor.
virtual ~IEEE1394grabber ()
 Destructor.
virtual GenericFrameSpec peekFrameSpec ()
 Return the specifications of the next frame to be returned.
virtual SimTime getNaturalFrameTime () const
 Get the inter-frame time that matches our video mode.
void grabPrealloc (Image< PixRGB< byte > > &image, pthread_mutex_t *lock=NULL, int *count=NULL)
 Grab video into a pre-allocated buffer.
virtual GenericFrame readFrame ()
 Get the next frame from the frame-grabber.

Protected Member Functions

VideoFrame grabRaw ()
 Grab raw data.
virtual void start1 ()
 get started
virtual void stop2 ()
 get stopped

Detailed Description

Definition and access functions for FireWire digital camera frame capture.

This class provides a trivial interface to FireWire digital cameras (i.e., web cams that send raw frame data over the firewire bus, not DV camcorders that send compressed video streams over the firewire bus). All the low-level setup is done during construction. The user only needs to call readFrame() or readRGB() to capture an image.

After each grab, the next grab is initiated, and will be ready 33ms later (or one frame later if not NTSC). If you call readFrame() again before 33ms have elapsed, it will block until the next frame is available. If you call it too late, you will have missed the latest frame, and readFrame() will block until the next frame is acquired.

So a good strategy is to use readFrame() to not only grab but also to synchronize your code with the video rate (30 frames/s if NTSC). Typically, then, you would have a main loop that first grabs and then does various processing that is guaranteed to take less than 33ms. You do not need to insert any pause after that processing to obtain a stable framerate; just finish your main loop, and the next call to readFrame() (at the next iteration) will block until exactly one frame has passed since it was last called. See how this is done, for example, in pvisionTCP-master.C or test-grab.C

Our Unibrain Fire-i rev 1.2 camera supports the following (use byteswap = false):

160 x 120: YUV444 (30, 15, 7.5 fps) 320 x 240: YUV422 (30, 15, 7.5, 3.75 fps) 640 x 480: YUV411 (30, 15, 7.5, 3.75 fps) 640 x 480: YUV422 (15, 7.5, 3.75 fps) 640 x 480: RGB24 (15, 7.5, 3.75 fps) 640 x 480: GREY (30, 15, 7.5, 3.75 fps)

To use this, you must have libdc1394 0.9.0 or later and libraw1394 0.9.0 or later installed (and your need the -devel RPMS installed as well to compile this code). Make sure you also have: mknod -m 777 /dev/raw1394 c 171 0 mkdir /dev/video1394 mknod -m 777 /dev/video1394/0 c 171 16

Definition at line 102 of file IEEE1394grabber.H.


Constructor & Destructor Documentation

IEEE1394grabber::IEEE1394grabber ( OptionManager mgr,
const std::string descrName = "IEEE1394 Frame Grabber Driver",
const std::string tagName = "IEEE1394FrameGrabber",
const ParamFlag  flags = USE_MY_VAL 
)

Constructor.

Definition at line 167 of file IEEE1394grabber.C.

References OptionManager::requestOptionAlias().

IEEE1394grabber::~IEEE1394grabber (  )  [virtual]

Destructor.

Definition at line 375 of file IEEE1394grabber.C.


Member Function Documentation

SimTime IEEE1394grabber::getNaturalFrameTime (  )  const [virtual]

Get the inter-frame time that matches our video mode.

Reimplemented from FrameIstream.

Definition at line 393 of file IEEE1394grabber.C.

References OModelParam< T >::getVal(), and SimTime::HERTZ().

void IEEE1394grabber::grabPrealloc ( Image< PixRGB< byte > > &  image,
pthread_mutex_t *  lock = NULL,
int *  count = NULL 
)

Grab video into a pre-allocated buffer.

This is faster than readFrame(), as here we will not allocate a new image for each grab, but rather we use an existing image. If not NULL, mutex 'lock' will be locked while the contents of image are being modified, and if not NULL count will be incremented by one. For IEEE1394, only YUV444 is supported.

Definition at line 399 of file IEEE1394grabber.C.

References ASSERT, Image< T >::beginw(), Image< T >::endw(), Image< T >::getHeight(), OModelParam< T >::getVal(), Image< T >::getWidth(), Dims::h(), image, ModelComponent::stop(), and Dims::w().

VideoFrame IEEE1394grabber::grabRaw (  )  [protected]

Grab raw data.

Don't call this directly; use readFrame() instead.

Definition at line 449 of file IEEE1394grabber.C.

References ASSERT, and OModelParam< T >::getVal().

Referenced by readFrame().

GenericFrameSpec IEEE1394grabber::peekFrameSpec (  )  [virtual]

Return the specifications of the next frame to be returned.

Implements FrameIstream.

Definition at line 379 of file IEEE1394grabber.C.

References OModelParam< T >::getVal().

GenericFrame IEEE1394grabber::readFrame (  )  [virtual]

Get the next frame from the frame-grabber.

Returns grabbed frame. This call will block until a frame is ready and has been grabbed.

Beware that the integrity of the GenericFrame object may not last "very long"; basically, try to be finished using the GenericFrame object before you attempt to grab the next frame in the stream. If you need it for longer than that, then you should use GenericFrame::deepCopyOf() to make a copy of the frame that can be safely held indefinitely.

Implements FrameIstream.

Definition at line 443 of file IEEE1394grabber.C.

References grabRaw().

void IEEE1394grabber::start1 (  )  [protected, virtual]

get started

Reimplemented from ModelComponent.

Definition at line 204 of file IEEE1394grabber.C.

References OModelParam< T >::getVal(), and IEEE1394GRABSPEED.

void IEEE1394grabber::stop2 (  )  [protected, virtual]

get stopped

Reimplemented from ModelComponent.

Definition at line 357 of file IEEE1394grabber.C.


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:22:17 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3