Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

BufferedImageGenerator Class Reference

#include <BufferedImageGenerator.h>

Inheritance diagram for BufferedImageGenerator:

List of all members.


Detailed Description

Receives camera frames as they are loaded by the simulator -- or eventually other sources.

Definition at line 9 of file BufferedImageGenerator.h.


Public Member Functions

 BufferedImageGenerator (const std::string &name, EventBase::EventGeneratorID_t mgid, unsigned int msid, unsigned int nLayers, EventBase::EventGeneratorID_t srcgid, unsigned int srcsid)
 constructor
virtual ~BufferedImageGenerator ()
 destructor
virtual void DoStart ()
 need to override EventGeneratorBase's lazy listening -- as a root stage, need to remember each frame, just in case it might be used
virtual void processEvent (const EventBase &event)
 default implementation does a few common housekeeping chores for you - probably should just take a look at its code
virtual unsigned int getBinSize () const
 Calculates space needed to save - if you can't precisely add up the size, just make sure to overestimate and things will still work.
virtual unsigned int loadBuffer (const char buf[], unsigned int len)
virtual unsigned int saveBuffer (char buf[], unsigned int len) const
 Save to a given buffer in memory.
virtual unsigned int saveFileStream (FILE *f) const
 overrridden to allow saving direct to file without an extra buffer copy
virtual void freeCaches ()
 deletes storage of cached images and marks it invalid
virtual void invalidateCaches ()
 marks all of the cached images as invalid (but doesn't free their memory)

Protected Member Functions

 BufferedImageGenerator (const std::string &classname, const std::string &instancename, EventBase::EventGeneratorID_t mgid, unsigned int msid, unsigned int nLayers, EventBase::EventGeneratorID_t srcgid, unsigned int srcsid)
 constructor for subclasses
virtual unsigned char * createImageCache (unsigned int layer, unsigned int channel) const
 create new image data storage area for the cache - this called by getImage() only when the corresponding entry in images is NULL
virtual void calcImage (unsigned int layer, unsigned int channel)
 should calculate new image data, called by getImage() only when imageValids indicates the image being requested is dirty (and only after getImage() has already called createImageCache())
virtual void setDimensions ()
 resets width and height parameters to that of the src
virtual void destruct ()
 deletes the arrays
virtual void setNumImages (unsigned int nLayers, unsigned int nChannels)
 resizes the filter bank information storage area, you should override this to do your setup and call it from your constructor
virtual void upsampleImage (unsigned int srcLayer, unsigned int chan, unsigned int destLayer)
 duplicates pixels to make a higher resolution version of srcLayer, chan into destLayer, chan
virtual void downsampleImage (unsigned int destLayer, unsigned int chan)
 averages blocks of pixels to make smaller images
virtual void calcDx (unsigned int layer, unsigned int srcChan=RawCameraGenerator::CHAN_Y, unsigned int dstChan=RawCameraGenerator::CHAN_Y_DX)
 calculates the x-derivative
virtual void calcDy (unsigned int layer, unsigned int srcChan=RawCameraGenerator::CHAN_Y, unsigned int dstChan=RawCameraGenerator::CHAN_Y_DY)
 calculates the x-derivative
virtual void calcDxDy (unsigned int layer)
 calculates the diagonal derivative

Protected Attributes

ImageSource imgsrc
 the data storage of the current image (not the image itself, but meta data a pointer to it)
bool ** isAllocated
 for each image in the filterbank, a bool to account whether the pointer is to an external resource or a self-allocated resource

Private Member Functions

 BufferedImageGenerator (const BufferedImageGenerator &)
 don't call
BufferedImageGeneratoroperator= (const BufferedImageGenerator &)
 don't call

Classes

struct  ImageSource
 Stores information about the current frame, (not the image itself, but meta data a pointer to it). More...

Constructor & Destructor Documentation

BufferedImageGenerator::BufferedImageGenerator ( const std::string &  name,
EventBase::EventGeneratorID_t  mgid,
unsigned int  msid,
unsigned int  nLayers,
EventBase::EventGeneratorID_t  srcgid,
unsigned int  srcsid 
) [inline]

constructor

Definition at line 35 of file BufferedImageGenerator.h.

virtual BufferedImageGenerator::~BufferedImageGenerator (  )  [inline, virtual]

destructor

Definition at line 48 of file BufferedImageGenerator.h.

BufferedImageGenerator::BufferedImageGenerator ( const std::string &  classname,
const std::string &  instancename,
EventBase::EventGeneratorID_t  mgid,
unsigned int  msid,
unsigned int  nLayers,
EventBase::EventGeneratorID_t  srcgid,
unsigned int  srcsid 
) [inline, protected]

constructor for subclasses

Definition at line 68 of file BufferedImageGenerator.h.

BufferedImageGenerator::BufferedImageGenerator ( const BufferedImageGenerator  )  [private]

don't call


Member Function Documentation

virtual void BufferedImageGenerator::DoStart (  )  [inline, virtual]

need to override EventGeneratorBase's lazy listening -- as a root stage, need to remember each frame, just in case it might be used

Reimplemented from EventGeneratorBase.

Definition at line 51 of file BufferedImageGenerator.h.

void BufferedImageGenerator::processEvent ( const EventBase event  )  [virtual]

default implementation does a few common housekeeping chores for you - probably should just take a look at its code

It doesn't throw any events for you - that's probably the main reason you'd still want to override it
Also, if your class has a set number of layers or channels - for instance, always 1 channel like InterleavedYUVGenerator, you should override setNumImages() to enforce that constraint by throwing away the appropriate argument and passing the your own value to the superclass implementation.

Reimplemented from FilterBankGenerator.

Definition at line 13 of file BufferedImageGenerator.cc.

unsigned int BufferedImageGenerator::getBinSize (  )  const [virtual]

Calculates space needed to save - if you can't precisely add up the size, just make sure to overestimate and things will still work.

getBinSize is used for reserving buffers during serialization, but does not necessarily determine the actual size of what is written -- the return value of saveBuffer() specifies that after the data actually has been written. If getBinSize overestimates, the extra memory allocation is only temporary, no extra filler bytes are actually stored.

Returns:
number of bytes read/written, 0 if error (or empty)

Reimplemented from FilterBankGenerator.

Definition at line 78 of file BufferedImageGenerator.cc.

unsigned int BufferedImageGenerator::loadBuffer ( const char  buf[],
unsigned int  len 
) [virtual]

The loadBuffer() functions of the included subclasses aren't tested, so don't assume they'll work without a little debugging...

Reimplemented from FilterBankGenerator.

Definition at line 86 of file BufferedImageGenerator.cc.

unsigned int BufferedImageGenerator::saveBuffer ( char  buf[],
unsigned int  len 
) const [virtual]

Save to a given buffer in memory.

Parameters:
buf pointer to the memory where you should begin writing
len length of buf available. (this isn't necessarily all yours, constrain yourself to what you returned in getBinSize() )
Returns:
the number of bytes actually used

Reimplemented from FilterBankGenerator.

Definition at line 111 of file BufferedImageGenerator.cc.

unsigned int BufferedImageGenerator::saveFileStream ( FILE *  f  )  const [virtual]

overrridden to allow saving direct to file without an extra buffer copy

Reimplemented from LoadSave.

Definition at line 152 of file BufferedImageGenerator.cc.

void BufferedImageGenerator::freeCaches (  )  [virtual]

deletes storage of cached images and marks it invalid

you should override this if the images cache pointer isn't actually an array of bytes... Don't forget to call it in your subclass's destructor or your version won't get called...

Reimplemented from FilterBankGenerator.

Definition at line 220 of file BufferedImageGenerator.cc.

Referenced by processEvent().

void BufferedImageGenerator::invalidateCaches (  )  [virtual]

marks all of the cached images as invalid (but doesn't free their memory)

You probably want to call this right before you send the FilterBankEvent

Reimplemented from FilterBankGenerator.

Definition at line 227 of file BufferedImageGenerator.cc.

Referenced by processEvent().

unsigned char * BufferedImageGenerator::createImageCache ( unsigned int  layer,
unsigned int  channel 
) const [protected, virtual]

create new image data storage area for the cache - this called by getImage() only when the corresponding entry in images is NULL

You should return the pointer you want stored in images to be returned by any calls to getFirstRow. Interpretation of the data it points to is dependant on the the generator which creates it

Implements FilterBankGenerator.

Definition at line 236 of file BufferedImageGenerator.cc.

Referenced by downsampleImage(), and loadBuffer().

void BufferedImageGenerator::calcImage ( unsigned int  layer,
unsigned int  channel 
) [protected, virtual]

should calculate new image data, called by getImage() only when imageValids indicates the image being requested is dirty (and only after getImage() has already called createImageCache())

This is where you'll want to put your user-specific code for calculating the image data

Implements FilterBankGenerator.

Definition at line 255 of file BufferedImageGenerator.cc.

void BufferedImageGenerator::setDimensions (  )  [protected, virtual]

resets width and height parameters to that of the src

You'll probably want to override this to also set skips and strides

Reimplemented from FilterBankGenerator.

Definition at line 284 of file BufferedImageGenerator.cc.

Referenced by processEvent(), and setNumImages().

void BufferedImageGenerator::destruct (  )  [protected, virtual]

deletes the arrays

Reimplemented from FilterBankGenerator.

Definition at line 317 of file BufferedImageGenerator.cc.

Referenced by ~BufferedImageGenerator().

void BufferedImageGenerator::setNumImages ( unsigned int  nLayers,
unsigned int  nChannels 
) [protected, virtual]

resizes the filter bank information storage area, you should override this to do your setup and call it from your constructor

In general, it isn't expected that FilterBankGenerator's should necessarily be dynamically resizeable (although it would be nice), which is why this isn't public. If yours is, just add some pubic accessor functions which call this. In general, the included subclasses should be able to handle being resized, but there's no reason to do so since the system won't be changing its available resolutions at run time.

The default implementation is a no-op if(numLayers==nLayers && numChannels==nChannels)

Reimplemented from FilterBankGenerator.

Definition at line 324 of file BufferedImageGenerator.cc.

Referenced by BufferedImageGenerator().

void BufferedImageGenerator::upsampleImage ( unsigned int  srcLayer,
unsigned int  chan,
unsigned int  destLayer 
) [protected, virtual]

duplicates pixels to make a higher resolution version of srcLayer, chan into destLayer, chan

Doesn't do anything fancy like blurring or smoothing

Definition at line 337 of file BufferedImageGenerator.cc.

Referenced by calcImage().

void BufferedImageGenerator::downsampleImage ( unsigned int  destLayer,
unsigned int  chan 
) [protected, virtual]

averages blocks of pixels to make smaller images

Definition at line 370 of file BufferedImageGenerator.cc.

Referenced by calcImage().

void BufferedImageGenerator::calcDx ( unsigned int  layer,
unsigned int  srcChan = RawCameraGenerator::CHAN_Y,
unsigned int  dstChan = RawCameraGenerator::CHAN_Y_DX 
) [protected, virtual]

calculates the x-derivative

Definition at line 403 of file BufferedImageGenerator.cc.

Referenced by calcDxDy(), and calcImage().

void BufferedImageGenerator::calcDy ( unsigned int  layer,
unsigned int  srcChan = RawCameraGenerator::CHAN_Y,
unsigned int  dstChan = RawCameraGenerator::CHAN_Y_DY 
) [protected, virtual]

calculates the x-derivative

Definition at line 426 of file BufferedImageGenerator.cc.

Referenced by calcDxDy(), and calcImage().

void BufferedImageGenerator::calcDxDy ( unsigned int  layer  )  [protected, virtual]

calculates the diagonal derivative

Definition at line 451 of file BufferedImageGenerator.cc.

Referenced by calcImage().

BufferedImageGenerator& BufferedImageGenerator::operator= ( const BufferedImageGenerator  )  [private]

don't call


Member Data Documentation

the data storage of the current image (not the image itself, but meta data a pointer to it)

Definition at line 90 of file BufferedImageGenerator.h.

Referenced by calcImage(), createImageCache(), downsampleImage(), processEvent(), setDimensions(), and upsampleImage().

for each image in the filterbank, a bool to account whether the pointer is to an external resource or a self-allocated resource

Definition at line 91 of file BufferedImageGenerator.h.

Referenced by createImageCache(), destruct(), freeCaches(), invalidateCaches(), processEvent(), and setNumImages().


The documentation for this class was generated from the following files:

Tekkotsu v4.0
Generated Thu Nov 22 00:58:12 2007 by Doxygen 1.5.4