GenericFrame Class Reference

Discriminated union of rgb, grayscale, floating-point, and video-yuv images. More...

#include <Raster/GenericFrame.H>

Collaboration diagram for GenericFrame:
Collaboration graph
[legend]

List of all members.

Classes

class  MetaData
 MetaData for storing frame spacific information. More...

Public Types

enum  NativeType {
  NONE = 0, RGB_U8 = 1, RGB_F32 = 5, GRAY_U8 = 2,
  GRAY_F32 = 3, VIDEO = 4, GRAY_U16 = 6, RGB_U16 = 7,
  RGBD = 8
}

Public Member Functions

 GenericFrame ()
 Construct an empty frame.
 GenericFrame (const Image< PixRGB< byte > > &rgbimg)
 Construct an 8-bit integer rgb-native frame.
 GenericFrame (const Image< PixRGB< byte > > &rgbimg, const Image< uint16 > &dimg)
 Construct an 8-bit integer rgb-native frame plus 16-bit depth image.
 GenericFrame (const Image< PixRGB< uint16 > > &rgbimg)
 Construct an 16-bit integer rgb-native frame.
 GenericFrame (const Layout< PixRGB< byte > > &rgbimg)
 Construct an 8-bit integer rgb-native frame from a layout.
 GenericFrame (const Image< PixRGB< float > > &rgbimg, const int flags)
 Construct a 32-bit floating point rgb-native frame.
 GenericFrame (const Image< byte > &grayimg)
 Construct an 8-bit integer grayscale-native frame.
 GenericFrame (const Image< uint16 > &grayimg)
 Construct an 16-bit integer grayscale-native frame.
 GenericFrame (const Layout< byte > &grayimg)
 Construct an 8-bit integer grayscale-native frame from a layout.
 GenericFrame (const Image< float > &floatimg, const int flags)
 Construct a 32-bit floating point grayscale-native frame.
 GenericFrame (const VideoFrame &vidframe)
 Construct an video-native frame.
bool initialized () const
 Check if we have a valid non-empty image, regardless of format.
GenericFrameSpec frameSpec () const
 Get the frame's specifications.
NativeType nativeType () const
 Get the frame's native image type.
std::string nativeTypeName () const
 Get the frame's native image typename.
Dims getDims () const
 Get the dimensions of the native image.
int getWidth () const
 Get the width of the native image.
int getHeight () const
 Get the height of the native image.
int floatFlags () const
 Get the float-normalization flags.
void setFloatFlags (int v)
 Change the float-normalization flags.
Image< PixRGB< byte > > asRgbU8 () const
 Get an 8-bit integer rgb version of the frame, converting as necessary.
Image< PixRGB< byte > > asRgb () const
Image< PixRGB< uint16 > > asRgbU16 () const
const Layout< PixRGB< byte > > & asRgbU8Layout () const
 Get an 8-bit integer rgb layout version of the frame, converting as necessary.
Image< PixRGB< float > > asRgbF32 () const
 Get a 32-bit float rgb version of the frame, converting as necessary.
Image< byteasGrayU8 () const
 Get an 8-bit integer grayscale version of the frame, converting as necessary.
Image< byteasGray () const
Image< uint16asGrayU16 () const
const Layout< byte > & asGrayU8Layout () const
 Get an 8-bit integer grayscale layout version of the frame, converting as necessary.
const Layout< byte > & asGrayU8NTSCLayout () const
 Get an 8-bit integer grayscale NTSC layout version of the frame, converting as necessary.
Image< float > asGrayF32 () const
 Get a 32-bit float grayscale version of the frame, converting as necessary.
Image< float > asFloat () const
Image< byteasGrayNTSC () const
 Convert the image from rgb to luminance in NTSC coordinates.
VideoFrame asVideo () const
 Get a video version of the frame, converting as necessary.
bool hasMetaData (const std::string &tag) const
 Check whether we have a given piece of metadata.
rutz::shared_ptr< MetaDatagetMetaData (const std::string &tag)
 Get a given piece of metadata or throw an exception if it doesn't exist.
void addMetaData (const std::string &tag, rutz::shared_ptr< MetaData > d)
 Insert a given piece of metadata, overwriting any previous metadata associated with that tag.

Static Public Member Functions

static GenericFrame deepCopyOf (const GenericFrame &f)
 Make a new GenericFrame object with an internal private copy of any transient data.

Detailed Description

Discriminated union of rgb, grayscale, floating-point, and video-yuv images.

This class allows frame sources (raster files, movie clips, frame-grabbers, etc.) to return frames in their optimal native representation, while deferring to the caller the ability to subsequently convert the frame to any convenient type. Similarly, GenericFrame objects can be passed to frame destinations (raster files, movie files, onscreen windows) in their native format, incurring as few conversions as possible.

Definition at line 60 of file GenericFrame.H.


Member Enumeration Documentation

Enumerator:
NONE 

no image

RGB_U8 

rgb color, 8 bits unsigned int per component

RGB_F32 

rgb color, 32 bits floating point per component

GRAY_U8 

grayscale, 8 bits unsigned int per pixel

GRAY_F32 

grayscale, 32 bits floating point per pixel

GRAY_U16 

grayscale, 16 bits unsigned uint per pixel

RGB_U16 

rgb color, 16 bits unsigned int per componet

RGBD 

8-bit rgb color plus 16-bit depth image

Definition at line 63 of file GenericFrame.H.


Constructor & Destructor Documentation

GenericFrame::GenericFrame (  ) 

Construct an empty frame.

Definition at line 59 of file GenericFrame.C.

GenericFrame::GenericFrame ( const Image< PixRGB< byte > > &  rgbimg  )  [explicit]

Construct an 8-bit integer rgb-native frame.

Definition at line 66 of file GenericFrame.C.

GenericFrame::GenericFrame ( const Image< PixRGB< byte > > &  rgbimg,
const Image< uint16 > &  dimg 
) [explicit]

Construct an 8-bit integer rgb-native frame plus 16-bit depth image.

Definition at line 76 of file GenericFrame.C.

References ASSERT.

GenericFrame::GenericFrame ( const Image< PixRGB< uint16 > > &  rgbimg  )  [explicit]

Construct an 16-bit integer rgb-native frame.

Definition at line 89 of file GenericFrame.C.

GenericFrame::GenericFrame ( const Layout< PixRGB< byte > > &  rgbimg  )  [explicit]

Construct an 8-bit integer rgb-native frame from a layout.

Definition at line 99 of file GenericFrame.C.

GenericFrame::GenericFrame ( const Image< PixRGB< float > > &  rgbimg,
const int  flags 
) [explicit]

Construct a 32-bit floating point rgb-native frame.

Parameters:
flags a bitwise-or'ed combination of FLOAT_NORM_0_255, FLOAT_NORM_WITH_SCALE, and FLOAT_NORM_PRESERVE (see Image/Normalize.H).

Definition at line 109 of file GenericFrame.C.

GenericFrame::GenericFrame ( const Image< byte > &  grayimg  )  [explicit]

Construct an 8-bit integer grayscale-native frame.

Definition at line 120 of file GenericFrame.C.

GenericFrame::GenericFrame ( const Image< uint16 > &  grayimg  )  [explicit]

Construct an 16-bit integer grayscale-native frame.

Definition at line 130 of file GenericFrame.C.

GenericFrame::GenericFrame ( const Layout< byte > &  grayimg  )  [explicit]

Construct an 8-bit integer grayscale-native frame from a layout.

Definition at line 140 of file GenericFrame.C.

GenericFrame::GenericFrame ( const Image< float > &  floatimg,
const int  flags 
) [explicit]

Construct a 32-bit floating point grayscale-native frame.

Parameters:
flags a bitwise-or'ed combination of FLOAT_NORM_0_255, FLOAT_NORM_WITH_SCALE, and FLOAT_NORM_PRESERVE (see Image/Normalize.H).

Definition at line 150 of file GenericFrame.C.

GenericFrame::GenericFrame ( const VideoFrame vidframe  )  [explicit]

Construct an video-native frame.

Definition at line 161 of file GenericFrame.C.


Member Function Documentation

void GenericFrame::addMetaData ( const std::string tag,
rutz::shared_ptr< MetaData d 
)

Insert a given piece of metadata, overwriting any previous metadata associated with that tag.

Definition at line 637 of file GenericFrame.C.

References rutz::shared_ptr< T >::get(), and rutz::shared_ptr< T >::reset().

Referenced by World3DInput::readFrame(), and XMLInput::readFrame().

Image< float > GenericFrame::asGrayF32 (  )  const
Image<byte> GenericFrame::asGrayNTSC (  )  const [inline]

Convert the image from rgb to luminance in NTSC coordinates.

Definition at line 189 of file GenericFrame.H.

References asGrayU8NTSCLayout().

Referenced by Raster::ReadGrayNTSC().

Image<byte> GenericFrame::asGrayU8 (  )  const [inline]
const Layout< byte > & GenericFrame::asGrayU8Layout (  )  const

Get an 8-bit integer grayscale layout version of the frame, converting as necessary.

Definition at line 375 of file GenericFrame.C.

References asRgbU8(), VideoFrame::getBuffer(), VideoFrame::getDims(), VideoFrame::getMode(), GRAY_F32, GRAY_U16, GRAY_U8, NONE, normalizeFloat(), RGB_F32, RGB_U16, RGB_U8, and RGBD.

Referenced by asGrayU8(), and ImageDisplayStream::writeFrame().

const Layout< byte > & GenericFrame::asGrayU8NTSCLayout (  )  const

Get an 8-bit integer grayscale NTSC layout version of the frame, converting as necessary.

Definition at line 434 of file GenericFrame.C.

References asRgbU8(), VideoFrame::getBuffer(), VideoFrame::getDims(), VideoFrame::getMode(), GRAY_F32, GRAY_U16, GRAY_U8, luminanceNTSC(), NONE, normalizeFloat(), RGB_F32, RGB_U16, RGB_U8, and RGBD.

Referenced by asGrayNTSC().

Image< PixRGB< float > > GenericFrame::asRgbF32 (  )  const
Image<PixRGB<byte> > GenericFrame::asRgbU8 (  )  const [inline]
const Layout< PixRGB< byte > > & GenericFrame::asRgbU8Layout (  )  const

Get an 8-bit integer rgb layout version of the frame, converting as necessary.

Definition at line 254 of file GenericFrame.C.

References GRAY_F32, GRAY_U16, GRAY_U8, NONE, normalizeFloat(), normalizeFloatRgb(), RGB_F32, RGB_U16, RGB_U8, RGBD, and VideoFrame::toRgb().

Referenced by asRgbU8(), and ImageDisplayStream::writeFrame().

VideoFrame GenericFrame::asVideo (  )  const
GenericFrame GenericFrame::deepCopyOf ( const GenericFrame f  )  [static]

Make a new GenericFrame object with an internal private copy of any transient data.

Definition at line 182 of file GenericFrame.C.

Referenced by DiskDataStream::writeFrame().

int GenericFrame::floatFlags (  )  const [inline]
GenericFrameSpec GenericFrame::frameSpec (  )  const
Dims GenericFrame::getDims (  )  const
int GenericFrame::getHeight ( void   )  const [inline]

Get the height of the native image.

Definition at line 150 of file GenericFrame.H.

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

Referenced by DisplayController::setBackground(), and MgzJEncoder::writeFrame().

rutz::shared_ptr< GenericFrame::MetaData > GenericFrame::getMetaData ( const std::string tag  ) 

Get a given piece of metadata or throw an exception if it doesn't exist.

Definition at line 621 of file GenericFrame.C.

References rutz::shared_ptr< T >::get().

Referenced by InferoTemporalSalBayes::attentionShift(), and InferoTemporalSIFT::attentionShift().

int GenericFrame::getWidth ( void   )  const [inline]

Get the width of the native image.

Definition at line 147 of file GenericFrame.H.

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

Referenced by DisplayController::setBackground(), and MgzJEncoder::writeFrame().

bool GenericFrame::hasMetaData ( const std::string tag  )  const

Check whether we have a given piece of metadata.

Definition at line 613 of file GenericFrame.C.

References rutz::shared_ptr< T >::get().

Referenced by InferoTemporalSalBayes::attentionShift(), and InferoTemporalSIFT::attentionShift().

bool GenericFrame::initialized (  )  const
NativeType GenericFrame::nativeType (  )  const [inline]
std::string GenericFrame::nativeTypeName (  )  const
void GenericFrame::setFloatFlags ( int  v  ) 

Change the float-normalization flags.

Definition at line 235 of file GenericFrame.C.

References GRAY_F32, and RGB_F32.

Referenced by MrawvEncoder::writeFrame().


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