FrameIstream Class Reference

Abstract interface class representing a source of Image frames. More...

#include <Transport/FrameIstream.H>

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

List of all members.

Public Member Functions

 FrameIstream (OptionManager &mgr, const std::string &descrName, const std::string &tagName)
 Constructor.
virtual ~FrameIstream ()
 Virtual destructor.
virtual void setConfigInfo (const std::string &cfg)
 Configure the FrameIstream object in a type-dependent manner.
virtual void setListener (rutz::shared_ptr< FrameListener > listener)
 Install a FrameListener; default implementation does nothing.
virtual bool setFrameNumber (int n)
 Advise the FrameIstream object of the current frame number.
virtual GenericFrameSpec peekFrameSpec ()=0
 Return the specifications of the next frame.
virtual SimTime getNaturalFrameTime () const
 Get the natural inter-frame time for this frame source.
Dims peekDims ()
 Convenience function to get the frame dims from peekFrameSpec().
int getWidth ()
 Convenience function to get the frame width from peekFrameSpec().
int getHeight ()
 Convenience function to get the frame height from peekFrameSpec().
virtual void startStream ()
 Optional call to efficiently prepare for frame streaming.
virtual GenericFrame readFrame ()=0
 Read a frame from the input source.
virtual Image< PixRGB< byte > > readRGB ()
 Read an image from the input source.
virtual Image< PixRGB< uint16 > > readRGBU16 ()
virtual Image< bytereadGray ()
 Read an image from the input source.
virtual Image< uint16readGrayU16 ()
virtual Image< float > readFloat ()
 Read an image from the input source.
virtual bool readAndDiscardFrame ()
 Read a frame from the stream and discard it.
virtual bool supportsSeek ()
 Return whether or not this stream supports seek operations.
virtual FrameRange getFrameRange ()
 Return the frame range for this particular input stream.

Detailed Description

Abstract interface class representing a source of Image frames.

Concrete classes might implement this interface so that the real source is a series of bitmap files (RasterInputSeries), or a movie file (InputMPEGSeries), or an external device (V4Lgrabber, IEEE1394grabber).

See also FrameOstream for the analogous output interface.

Definition at line 71 of file FrameIstream.H.


Constructor & Destructor Documentation

FrameIstream::FrameIstream ( OptionManager mgr,
const std::string descrName,
const std::string tagName 
)

Constructor.

Definition at line 52 of file FrameIstream.C.

FrameIstream::~FrameIstream (  )  [virtual]

Virtual destructor.

Definition at line 59 of file FrameIstream.C.


Member Function Documentation

FrameRange FrameIstream::getFrameRange (  )  [virtual]

Return the frame range for this particular input stream.

This is particuarly applicable for FrameIstreams dealing with video files and image directories, in which case it may be easier to get this value from the underlying FrameIstream, rather than the command line. The default behavior is to just return the default empty FrameRange, but should be overloaded for stream sources which can return sensical ranges.

Reimplemented in MgzJInputStream.

Definition at line 144 of file FrameIstream.C.

int FrameIstream::getHeight ( void   ) 

Convenience function to get the frame height from peekFrameSpec().

Definition at line 97 of file FrameIstream.C.

References Dims::h(), and peekFrameSpec().

SimTime FrameIstream::getNaturalFrameTime (  )  const [virtual]

Get the natural inter-frame time for this frame source.

A return value of 0 means that there is no particular natural inter-frame time; the default implementation returns 0 so subclasses should override if they need to specify a different inter-frame time.

This information should be treated as advisory only; for instance, callers might use this information to try to display frames to the user at the "natural" framerate.

Reimplemented in DC1394Grabber2, IEEE1394grabber, RTSPGrabber, V4L2grabber, V4Lgrabber, XCgrabber, XCgrabberFlex, BobDeinterlacer, BufferedFrameIstream, and Stimulus2D.

Definition at line 82 of file FrameIstream.C.

References SimTime::ZERO().

Referenced by BobDeinterlacer::start2().

int FrameIstream::getWidth ( void   ) 

Convenience function to get the frame width from peekFrameSpec().

Definition at line 92 of file FrameIstream.C.

References peekFrameSpec(), and Dims::w().

Dims FrameIstream::peekDims (  ) 

Convenience function to get the frame dims from peekFrameSpec().

Definition at line 87 of file FrameIstream.C.

References peekFrameSpec().

virtual GenericFrameSpec FrameIstream::peekFrameSpec (  )  [pure virtual]
bool FrameIstream::readAndDiscardFrame (  )  [virtual]

Read a frame from the stream and discard it.

Subclasses may be able to implement this function more efficiently than the other functions that actually return an Image object (since they might avoid converting from some raw representation to Image). So, if you know you are going to discard the frame (e.g. to skip ahead to a certain frame number, or to count the frame), then it is more efficient to call readAndDiscardFrame() than to call readVideoFrame() or readRGB() but ignore the result.

The return value will be true if a frame was actually read, or false if no frame was found (e.g., end-of-stream was reached).

The default implementation just calls readRGB() but ignores the result.

Reimplemented in MgzJInputStream, and InputMPEGStream.

Definition at line 133 of file FrameIstream.C.

References GenericFrame::initialized(), and readFrame().

Image< float > FrameIstream::readFloat (  )  [virtual]

Read an image from the input source.

The actual input source could be a raster file, a movie file, or some external device, etc., depending on the concrete subclass.

The default implementation just returns readFrame().asFloat().

Definition at line 128 of file FrameIstream.C.

References readFrame().

virtual GenericFrame FrameIstream::readFrame (  )  [pure virtual]
Image< byte > FrameIstream::readGray (  )  [virtual]

Read an image from the input source.

The actual input source could be a raster file, a movie file, or some external device, etc., depending on the concrete subclass.

The default implementation just returns readFrame().asGray().

Definition at line 118 of file FrameIstream.C.

References readFrame().

Image< uint16 > FrameIstream::readGrayU16 (  )  [virtual]

the specific 12 bit depth (actually any uint16 data type) implemtation return from readFrame().asRgb16().

Definition at line 123 of file FrameIstream.C.

References readFrame().

Image< PixRGB< byte > > FrameIstream::readRGB (  )  [virtual]

Read an image from the input source.

The actual input source could be a raster file, a movie file, or some external device, etc., depending on the concrete subclass.

The default implementation just returns readFrame().asRgb().

Reimplemented in InputMPEGStream.

Definition at line 108 of file FrameIstream.C.

References readFrame().

Image< PixRGB< uint16 > > FrameIstream::readRGBU16 (  )  [virtual]

the specific 12 bit depth (actually any uint16 data type) implemtation return from readFrame().asRgb16().

Definition at line 113 of file FrameIstream.C.

References readFrame().

void FrameIstream::setConfigInfo ( const std::string cfg  )  [virtual]

Configure the FrameIstream object in a type-dependent manner.

The string is expected to be some piece of user input (e.g. from the command-line) specifying key information for the FrameIstream (e.g., the filename for an input movie).

The default implementation does nothing; derived classes can override if they need to receive such user input.

Reimplemented in RTSPGrabber, MgzInputStream, MgzJInputStream, InputMPEGStream, MrawvInputStream, SequenceFileStream, BarStimuli, BufferedFrameIstream, ColorbarsInput, Deinterlacer, DotStimuli, GameOfLifeInput, RandomInput, RasterInputSeries, RasterlistInputSeries, ShiftedImage, Stimulus2D, World2DInput, World3DInput, and XMLInput.

Definition at line 62 of file FrameIstream.C.

bool FrameIstream::setFrameNumber ( int  n  )  [virtual]

Advise the FrameIstream object of the current frame number.

NOTE: the default implementation does nothing -- it just ignores the frame number. This is allowed for subclasses, too, since for certain input formats (e.g., framegrabbers) it doesn't make any sense to specify a frame number, since the format doesn't support random-access reading. On the other hand, certain subclasses require a frame number to function properly (e.g., for writing a series of consecutively-numbered raster files). So, the bottom line is: clients of FrameIstream must be sure to call setFrameNumber(), but should make no assumptions about what it will actually do.

Returns:
Whether the frame number was succesfully set as requested. The function may fail, for instance, in the case of an input source like a movie file that has only a limited number of frames.

Reimplemented in InputFrameSeries, MgzJInputStream, InputMPEGStream, SequenceFileStream, BobDeinterlacer, BufferedFrameIstream, ColorbarsInput, HalfFieldDeinterlacer< BottomField >, RasterInputSeries, RasterlistInputSeries, Stimulus2D, and XMLInput.

Definition at line 74 of file FrameIstream.C.

Referenced by HalfFieldDeinterlacer< BottomField >::setFrameNumber(), and BobDeinterlacer::setFrameNumber().

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

Install a FrameListener; default implementation does nothing.

Subclasses may override this method if they want to actually pass some information to the listener.

Reimplemented in V4L2grabber, V4Lgrabber, and BobDeinterlacer.

Definition at line 68 of file FrameIstream.C.

Referenced by BobDeinterlacer::setListener().

void FrameIstream::startStream (  )  [virtual]

Optional call to efficiently prepare for frame streaming.

Some FrameIstream subclasses may require some preparatory work before they can start returning image frames, and this function lets that work be done outside of the application's main frame-reading loop.

A good example of this is streaming-mode frame-grabbers, such as the video4linux driver. To use that driver in streaming mode, each of the internal frame buffers must be started, but they shouldn't be started "too soon" either; so, it's best to call startStream() just before the main loops starts calling readFrame() (or readRGB(), etc.).

Subclass authors should design their classes so that readFrame() always "just works", regardless of whether the user has called startStream() or not, typically by keeping a flag to mark whether startStream() has been called, and then calling startStream() from within the first readFrame() call, if needed.

The default implementation of startStream() is a no-op.

Reimplemented in QuickTimeGrabber, V4L2grabber, V4Lgrabber, InputFrameSeries, BobDeinterlacer, BufferedFrameIstream, and HalfFieldDeinterlacer< BottomField >.

Definition at line 102 of file FrameIstream.C.

Referenced by HalfFieldDeinterlacer< BottomField >::startStream(), and BobDeinterlacer::startStream().

bool FrameIstream::supportsSeek (  )  [virtual]

Return whether or not this stream supports seek operations.

This function should be reimplemented in subclasses to let users know whether or not random frame access is supported. The default implementation returns false.

Reimplemented in MgzJInputStream, and RasterInputSeries.

Definition at line 139 of file FrameIstream.C.


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