Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
#include <FilterBankGenerator.h>
Inheritance diagram for FilterBankGenerator:
This is needed to provide an interface for the FilterBankEvent to call back when the actual image data is requested from it. This facilitates lazy calculation of image data... no sense in processing layers or channels which aren't actually going to be used...
Also this way we save on allocating/deallocating large memory blocks on each event... the buffers allocated here can be reused frame to frame.
Larger layer indicies generally indicate higher resolution images in a scaling pyramid, but you are free to store your own data however you wish.
For serializing, FilterBankGenerators inherit from the LoadSave interface. Only one image (selected with setLoadSaveImage()) of the bank will loaded or saved at a time. The default LoadSave will store some header information for you:
However, you will need to override the LoadSave functions (listed below) to provide your own code for interpreting the image data itself. You may also want to add a few extra functions to allow users to set compression/data format parameters.
If you're doing fancy memory stuff, you probably want to override the freeCaches() and destruct() functions so that the default implementation won't try to free something it shouldn't. Don't forget to call them from your own destructor though, otherwise your versions won't get called before the default implementation's does.
Definition at line 48 of file FilterBankGenerator.h.
Public Member Functions | |
FilterBankGenerator () | |
constructor, calls setNumImages(1,1) | |
FilterBankGenerator (unsigned int layers, unsigned int channels) | |
constructor | |
FilterBankGenerator (const std::string &name, unsigned int layers, unsigned int channels, EventBase::EventGeneratorID_t srcgid, unsigned int srcsid, EventBase::EventGeneratorID_t mgid, unsigned int msid) | |
constructor | |
~FilterBankGenerator () | |
destructor | |
virtual unsigned int | getNumLayers () const |
returns the number of image layers (e.g. different resolutions available) | |
virtual unsigned int | getNumChannels () const |
returns the number of channels per image (e.g. Y, U, or V components) | |
virtual unsigned char * | getImage (unsigned int layer, unsigned int channel) const |
returns pointer to the beginning of the image data for the specified layer and channel | |
unsigned int | getWidth (unsigned int layer) const |
returns width (in samples) of the image in a given layer | |
unsigned int | getHeight (unsigned int layer) const |
returns height (in samples) of the image in a given layer | |
unsigned int | getSkip (unsigned int layer) const |
returns the bytes to skip from the one-past-end of a row to get the beginning of the next | |
unsigned int | getStride (unsigned int layer) const |
returns the bytes to skip from the beginning of one row to get the beginning of the next | |
unsigned int | getIncrement (unsigned int layer) const |
returns the increment (in bytes) to use to go from one sample to the next | |
unsigned int | getFrameNumber () const |
returns the frame number of the current frame, see frameNumber | |
unsigned int | getFramesProcessed () const |
returns the number of frames processed, see framesProcessed | |
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) | |
virtual void | processEvent (const EventBase &) |
default implementation ignore events, just so you don't have to define it if you don't receive events | |
LoadSave interface | |
virtual unsigned int | getBinSize () const |
calculates space needed to save - if you can't precisely add up the size, 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. | |
virtual void | selectSaveImage (unsigned int layer, unsigned int channel) |
not actually part of the LoadSave interface, but allows you to select which image of the bank will be saved | |
virtual unsigned int | getSelectedSaveLayer () const |
returns layer to be saved, or layer of last image loaded | |
virtual unsigned int | getSelectedSaveChannel () const |
returns channel to be saved, or channel of last image loaded | |
Protected Member Functions | |
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 unsigned char * | createImageCache (unsigned int layer, unsigned int channel) const =0 |
create new image data storage area for the cache - this is only called when the corresponding entry in images is NULL | |
virtual void | calcImage (unsigned int layer, unsigned int channel) const =0 |
should calculate new image data, only called when imageValids indicates the image being requested is dirty | |
virtual void | destruct () |
deletes the arrays | |
Protected Attributes | |
unsigned int | numLayers |
current number of layers available | |
unsigned int | numChannels |
current number of channels available | |
unsigned int * | widths |
an array of size numLayers, width (in samples) in pixels of each layer | |
unsigned int * | heights |
an array of size numLayers, height (in samples) in pixels of each layer | |
unsigned int * | skips |
an array of size numLayers, skip (in bytes) from row end to next row begin | |
unsigned int * | strides |
an array of size numLayers, stride (in bytes) from a given column in one row to the same column in the next row | |
unsigned int * | increments |
an array of size numLayers, increment (in bytes) to use to get from one sample to the next | |
unsigned char *** | images |
an array [numLayers][numChannels], stores pointer to cached image data | |
bool ** | imageValids |
an array [numLayers][numChannels], entry is true if cached data is still valid | |
unsigned int | selectedSaveLayer |
layer to be manipulated with the LoadSave functions | |
unsigned int | selectedSaveChannel |
channel to be manipulated with the LoadSave functions | |
unsigned int | frameNumber |
the current frame number - subclasses will need to set to the source's frameNumber when they receive a new frame (probably from processEvent()) | |
unsigned int | framesProcessed |
subclasses should increment this any time they make a new filter bank available (probably by throwing an event) | |
Private Member Functions | |
FilterBankGenerator (const FilterBankGenerator &fbk) | |
don't call | |
const FilterBankGenerator & | operator= (const FilterBankGenerator &fbk) |
don't call |
|
constructor, calls setNumImages(1,1)
Definition at line 51 of file FilterBankGenerator.h. |
|
constructor
Definition at line 58 of file FilterBankGenerator.h. |
|
constructor
Definition at line 65 of file FilterBankGenerator.h. |
|
destructor
Definition at line 72 of file FilterBankGenerator.h. |
|
don't call
|
|
should calculate new image data, only called when imageValids indicates the image being requested is dirty This is where you'll want to put your user-specific code for calculating the image data Implemented in CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator. Referenced by getImage(). |
|
create new image data storage area for the cache - this is only called 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 Implemented in CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator. Referenced by getImage(). |
|
deletes the arrays
Reimplemented in CDTGenerator, JPEGGenerator, RawCameraGenerator, RegionGenerator, and RLEGenerator. Definition at line 106 of file FilterBankGenerator.cc. Referenced by RLEGenerator::destruct(), RegionGenerator::destruct(), RawCameraGenerator::destruct(), JPEGGenerator::destruct(), CDTGenerator::destruct(), setNumImages(), and ~FilterBankGenerator(). |
|
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 in CDTGenerator, RawCameraGenerator, and RegionGenerator. Definition at line 17 of file FilterBankGenerator.cc. Referenced by RegionGenerator::freeCaches(), RawCameraGenerator::freeCaches(), CDTGenerator::freeCaches(), setNumImages(), ~FilterBankGenerator(), JPEGGenerator::~JPEGGenerator(), and RLEGenerator::~RLEGenerator(). |
|
calculates space needed to save - if you can't precisely add up the size, overestimate and things will still work.
Implements LoadSave. Reimplemented in CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator. Definition at line 34 of file FilterBankGenerator.cc. Referenced by SegmentedColorGenerator::getBinSize(), RLEGenerator::getBinSize(), RegionGenerator::getBinSize(), RawCameraGenerator::getBinSize(), JPEGGenerator::getBinSize(), InterleavedYUVGenerator::getBinSize(), and CDTGenerator::getBinSize(). |
|
returns the frame number of the current frame, see frameNumber
Definition at line 104 of file FilterBankGenerator.h. Referenced by FilterBankEvent::getFrameNumber(), SegCamBehavior::openPacket(), RawCamBehavior::openPacket(), SegmentedColorGenerator::processEvent(), RLEGenerator::processEvent(), RegionGenerator::processEvent(), JPEGGenerator::processEvent(), and InterleavedYUVGenerator::processEvent(). |
|
returns the number of frames processed, see framesProcessed
Definition at line 107 of file FilterBankGenerator.h. Referenced by FilterBankEvent::getFramesProcessed(). |
|
returns height (in samples) of the image in a given layer
Definition at line 91 of file FilterBankGenerator.h. Referenced by RLEGenerator::calcExpMaxRuns(), SegmentedColorGenerator::calcImage(), RLEGenerator::calcImage(), RawCameraGenerator::calcImage(), InterleavedYUVGenerator::calcImage(), FilterBankEvent::getHeight(), SegCamBehavior::openPacket(), RawCamBehavior::openPacket(), RawCameraGenerator::processEvent(), CDTGenerator::processEvent(), SegmentedColorGenerator::setDimensions(), RLEGenerator::setDimensions(), RegionGenerator::setDimensions(), JPEGGenerator::setDimensions(), and InterleavedYUVGenerator::setDimensions(). |
|
returns pointer to the beginning of the image data for the specified layer and channel this will cause the data to be calculated and cached if it's not already available Definition at line 5 of file FilterBankGenerator.cc. Referenced by SegmentedColorGenerator::calcImage(), RLEGenerator::calcImage(), RegionGenerator::calcImage(), JPEGGenerator::calcImage(), InterleavedYUVGenerator::calcImage(), FilterBankEvent::getImage(), RLEGenerator::getNumRuns(), RLEGenerator::getRun(), RLEGenerator::getRuns(), JPEGGenerator::LoadBuffer(), CameraBehavior::processEvent(), RawCameraGenerator::reconstructImage(), SegmentedColorGenerator::SaveBuffer(), RLEGenerator::SaveBuffer(), RegionGenerator::SaveBuffer(), RawCameraGenerator::SaveBuffer(), JPEGGenerator::SaveBuffer(), InterleavedYUVGenerator::SaveBuffer(), CDTGenerator::SaveBuffer(), and RawCameraGenerator::upsampleImage(). |
|
returns the increment (in bytes) to use to go from one sample to the next
Definition at line 101 of file FilterBankGenerator.h. Referenced by InterleavedYUVGenerator::calcImage(), FilterBankEvent::getIncrement(), RawCameraGenerator::SaveBuffer(), and CDTGenerator::SaveBuffer(). |
|
returns the number of channels per image (e.g. Y, U, or V components)
Definition at line 81 of file FilterBankGenerator.h. Referenced by FilterBankEvent::getNumChannels(), SegmentedColorGenerator::processEvent(), RLEGenerator::processEvent(), RegionGenerator::processEvent(), JPEGGenerator::processEvent(), and InterleavedYUVGenerator::processEvent(). |
|
returns the number of image layers (e.g. different resolutions available)
Definition at line 78 of file FilterBankGenerator.h. Referenced by FilterBankEvent::getNumLayers(), SegmentedColorGenerator::processEvent(), RLEGenerator::processEvent(), RegionGenerator::processEvent(), JPEGGenerator::processEvent(), InterleavedYUVGenerator::processEvent(), RawCamBehavior::writeColor(), SegCamBehavior::writeRLE(), SegCamBehavior::writeSeg(), and RawCamBehavior::writeSingleChannel(). |
|
returns channel to be saved, or channel of last image loaded
Definition at line 134 of file FilterBankGenerator.h. |
|
returns layer to be saved, or layer of last image loaded
Definition at line 133 of file FilterBankGenerator.h. |
|
returns the bytes to skip from the one-past-end of a row to get the beginning of the next
Definition at line 94 of file FilterBankGenerator.h. Referenced by InterleavedYUVGenerator::calcImage(), FilterBankEvent::getSkip(), RawCameraGenerator::reconstructImage(), RawCameraGenerator::SaveBuffer(), CDTGenerator::SaveBuffer(), and RawCameraGenerator::upsampleImage(). |
|
returns the bytes to skip from the beginning of one row to get the beginning of the next This is just for convenience; the stride is just the skip plus the width, but it's precomputed for you for speed and clarity Definition at line 98 of file FilterBankGenerator.h. Referenced by SegmentedColorGenerator::calcImage(), RawCameraGenerator::calcImage(), JPEGGenerator::calcImage(), and FilterBankEvent::getStride(). |
|
|
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 Definition at line 27 of file FilterBankGenerator.cc. Referenced by freeCaches(), SegmentedColorGenerator::processEvent(), RLEGenerator::processEvent(), RegionGenerator::processEvent(), RawCameraGenerator::processEvent(), JPEGGenerator::processEvent(), InterleavedYUVGenerator::processEvent(), CDTGenerator::processEvent(), and JPEGGenerator::setQuality(). |
|
The LoadBuffer() functions of the included subclasses aren't tested, so don't assume they'll work without a little debugging... Implements LoadSave. Reimplemented in CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator. Definition at line 45 of file FilterBankGenerator.cc. Referenced by SegmentedColorGenerator::LoadBuffer(), RLEGenerator::LoadBuffer(), RegionGenerator::LoadBuffer(), RawCameraGenerator::LoadBuffer(), JPEGGenerator::LoadBuffer(), and InterleavedYUVGenerator::LoadBuffer(). |
|
don't call
|
|
default implementation ignore events, just so you don't have to define it if you don't receive events
Reimplemented from BehaviorBase. Reimplemented in CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator. Definition at line 119 of file FilterBankGenerator.h. |
|
Save to a given buffer.
Implements LoadSave. Reimplemented in CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator. Definition at line 61 of file FilterBankGenerator.cc. Referenced by SegmentedColorGenerator::SaveBuffer(), RLEGenerator::SaveBuffer(), RegionGenerator::SaveBuffer(), RawCameraGenerator::SaveBuffer(), JPEGGenerator::SaveBuffer(), InterleavedYUVGenerator::SaveBuffer(), CDTGenerator::SaveBuffer(), RawCamBehavior::writeColor(), SegCamBehavior::writeSeg(), and RawCamBehavior::writeSingleChannel(). |
|
not actually part of the LoadSave interface, but allows you to select which image of the bank will be saved when loading, the saved image's layer and channel will reset this Definition at line 131 of file FilterBankGenerator.h. Referenced by CameraBehavior::processEvent(), RawCamBehavior::writeColor(), SegCamBehavior::writeRLE(), SegCamBehavior::writeSeg(), and RawCamBehavior::writeSingleChannel(). |
|
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. Reimplemented in CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator. Definition at line 78 of file FilterBankGenerator.cc. Referenced by FilterBankGenerator(), SegmentedColorGenerator::setNumImages(), RLEGenerator::setNumImages(), RegionGenerator::setNumImages(), RawCameraGenerator::setNumImages(), JPEGGenerator::setNumImages(), InterleavedYUVGenerator::setNumImages(), and CDTGenerator::setNumImages(). |
|
the current frame number - subclasses will need to set to the source's frameNumber when they receive a new frame (probably from processEvent()) The idea is to use this as a unique serial number for each frame. That way you can know if the current image in different generators is actually the same camera image before you try to compare or combine them. You could also figure out the number of dropped frames by subtracting framesProcessed from this value. Give some leeway however, because it takes the first 40-70 frames just to boot up, so there's no way they can be processed. Definition at line 190 of file FilterBankGenerator.h. Referenced by FilterBankGenerator(), getFrameNumber(), SegmentedColorGenerator::processEvent(), RLEGenerator::processEvent(), RegionGenerator::processEvent(), RawCameraGenerator::processEvent(), JPEGGenerator::processEvent(), InterleavedYUVGenerator::processEvent(), and CDTGenerator::processEvent(). |
|
subclasses should increment this any time they make a new filter bank available (probably by throwing an event)
Definition at line 191 of file FilterBankGenerator.h. Referenced by FilterBankGenerator(), getFramesProcessed(), SegmentedColorGenerator::processEvent(), RLEGenerator::processEvent(), RegionGenerator::processEvent(), RawCameraGenerator::processEvent(), JPEGGenerator::processEvent(), InterleavedYUVGenerator::processEvent(), and CDTGenerator::processEvent(). |
|
|
an array [numLayers][numChannels], stores pointer to cached image data
Definition at line 173 of file FilterBankGenerator.h. Referenced by SegmentedColorGenerator::calcImage(), RLEGenerator::calcImage(), RegionGenerator::calcImage(), RawCameraGenerator::calcImage(), JPEGGenerator::calcImage(), InterleavedYUVGenerator::calcImage(), CDTGenerator::calcImage(), destruct(), FilterBankGenerator(), RawCameraGenerator::freeCaches(), freeCaches(), CDTGenerator::freeCaches(), getImage(), SegmentedColorGenerator::LoadBuffer(), RLEGenerator::LoadBuffer(), RegionGenerator::LoadBuffer(), RawCameraGenerator::LoadBuffer(), JPEGGenerator::LoadBuffer(), InterleavedYUVGenerator::LoadBuffer(), RawCameraGenerator::reconstructImage(), setNumImages(), and RawCameraGenerator::upsampleImage(). |
|
an array [numLayers][numChannels], entry is true if cached data is still valid
Definition at line 174 of file FilterBankGenerator.h. Referenced by SegmentedColorGenerator::calcImage(), RLEGenerator::calcImage(), RegionGenerator::calcImage(), RawCameraGenerator::calcImage(), JPEGGenerator::calcImage(), InterleavedYUVGenerator::calcImage(), CDTGenerator::calcImage(), destruct(), FilterBankGenerator(), RawCameraGenerator::freeCaches(), CDTGenerator::freeCaches(), RLEGenerator::getBinSize(), RegionGenerator::getBinSize(), getImage(), RLEGenerator::getNumRuns(), invalidateCaches(), SegmentedColorGenerator::LoadBuffer(), RLEGenerator::LoadBuffer(), RegionGenerator::LoadBuffer(), RawCameraGenerator::LoadBuffer(), JPEGGenerator::LoadBuffer(), InterleavedYUVGenerator::LoadBuffer(), and setNumImages(). |
|
an array of size numLayers, increment (in bytes) to use to get from one sample to the next
Definition at line 171 of file FilterBankGenerator.h. Referenced by destruct(), FilterBankGenerator(), getIncrement(), RawCameraGenerator::setDimensions(), CDTGenerator::setDimensions(), RawCameraGenerator::setNumImages(), JPEGGenerator::setNumImages(), InterleavedYUVGenerator::setNumImages(), setNumImages(), and CDTGenerator::setNumImages(). |
|
|
|
|
|
an array of size numLayers, skip (in bytes) from row end to next row begin
Definition at line 169 of file FilterBankGenerator.h. Referenced by destruct(), FilterBankGenerator(), getSkip(), RawCameraGenerator::processEvent(), CDTGenerator::processEvent(), SegmentedColorGenerator::setDimensions(), RawCameraGenerator::setDimensions(), JPEGGenerator::setDimensions(), InterleavedYUVGenerator::setDimensions(), CDTGenerator::setDimensions(), and setNumImages(). |
|
an array of size numLayers, stride (in bytes) from a given column in one row to the same column in the next row
Definition at line 170 of file FilterBankGenerator.h. Referenced by destruct(), FilterBankGenerator(), getStride(), RawCameraGenerator::processEvent(), CDTGenerator::processEvent(), SegmentedColorGenerator::setDimensions(), RawCameraGenerator::setDimensions(), JPEGGenerator::setDimensions(), InterleavedYUVGenerator::setDimensions(), CDTGenerator::setDimensions(), and setNumImages(). |
|
Tekkotsu v2.0 |
Generated Wed Jan 21 03:23:12 2004 by Doxygen 1.3.4 |