V4L2grabber Class Reference

Definition and access functions for video4linux2 frame grabber. More...

#include <Devices/V4L2grabber.H>

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

List of all members.

Classes

class  V4L2grabberControl
class  V4L2grabberControlBase

Public Member Functions

 V4L2grabber (OptionManager &mgr, const std::string &descrName="V4L Frame Grabber Driver", const std::string &tagName="V4LFrameGrabber", const ParamFlag flags=USE_MY_VAL)
 Constructor.
virtual ~V4L2grabber ()
 Destructor.
virtual void setListener (rutz::shared_ptr< FrameListener > listener)
 Install a FrameListener.
virtual void startStream ()
 Get a streaming grab started.
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.
virtual GenericFrame readFrame ()
 Get the next frame from the frame-grabber.

Protected Member Functions

VideoFrame grabRaw ()
 Grab a raw VideoFrame.
VideoFrame grabSingleRaw ()
 Grab a single VideoFrame.
virtual void start1 ()
 get started
virtual void stop2 ()
 get stopped

Detailed Description

Definition and access functions for video4linux2 frame grabber.

This class provides a trivial interface to Video4Linux2 frame grabbers. All the low-level setup is done during construction. The user only needs to call readRGB() or readFrame() to capture an image. Shared memory and DMA directly from the grabber hardware into our memory is used if supported by the grabber and driver. This should work with any framegrabber that is supported by Video4Linux. We use Bt878-based boards.

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

Definition at line 81 of file V4L2grabber.H.


Constructor & Destructor Documentation

V4L2grabber::V4L2grabber ( OptionManager mgr,
const std::string descrName = "V4L Frame Grabber Driver",
const std::string tagName = "V4LFrameGrabber",
const ParamFlag  flags = USE_MY_VAL 
)

Constructor.

Definition at line 194 of file V4L2grabber.C.

References OPT_ALIAScamMacbook, and OptionManager::requestOptionAlias().

V4L2grabber::~V4L2grabber (  )  [virtual]

Destructor.

Definition at line 671 of file V4L2grabber.C.


Member Function Documentation

SimTime V4L2grabber::getNaturalFrameTime (  )  const [virtual]

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

Reimplemented from FrameIstream.

Definition at line 796 of file V4L2grabber.C.

VideoFrame V4L2grabber::grabRaw (  )  [protected]

Grab a raw VideoFrame.

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

Definition at line 830 of file V4L2grabber.C.

References ASSERT, Image< T >::getArrayPtr(), Image< T >::getSize(), OModelParam< T >::getVal(), and Image< T >::initialized().

Referenced by readFrame().

VideoFrame V4L2grabber::grabSingleRaw (  )  [protected]

Grab a single VideoFrame.

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

This function will work better with single-shot grabs (as opposed to video) and USB cameras.

Definition at line 890 of file V4L2grabber.C.

References ASSERT, Image< T >::getArrayPtr(), Image< T >::getSize(), OModelParam< T >::getVal(), and Image< T >::initialized().

Referenced by readFrame().

GenericFrameSpec V4L2grabber::peekFrameSpec (  )  [virtual]

Return the specifications of the next frame to be returned.

Implements FrameIstream.

Definition at line 802 of file V4L2grabber.C.

References OModelParam< T >::getVal().

GenericFrame V4L2grabber::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 816 of file V4L2grabber.C.

References rutz::shared_ptr< T >::get(), OModelParam< T >::getVal(), grabRaw(), and grabSingleRaw().

void V4L2grabber::setListener ( rutz::shared_ptr< FrameListener listener  )  [virtual]

Install a FrameListener.

We call the listener's onRawFrame() inside each readFrame().

Reimplemented from FrameIstream.

Definition at line 675 of file V4L2grabber.C.

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

get started

Reimplemented from ModelComponent.

Definition at line 518 of file V4L2grabber.C.

References getFrameSize(), OModelParam< T >::getVal(), Dims::h(), SimTime::HERTZ(), SimTime::hertz(), NO_INIT, SimTime::SECS(), and Dims::w().

void V4L2grabber::startStream (  )  [virtual]

Get a streaming grab started.

This will instruct the grabber to grab all of its possible buffers, one after the other. Typically you should call this just before you start reading frames. If the option --framegrabber-streaming=false is set, then this call is a (safe) no-op.

Reimplemented from FrameIstream.

Definition at line 786 of file V4L2grabber.C.

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

get stopped

Reimplemented from ModelComponent.

Definition at line 665 of file V4L2grabber.C.


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