| Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
FilterBankGenerator Class Reference#include <FilterBankGenerator.h>
Inheritance diagram for FilterBankGenerator: ![]() Detailed DescriptionAbstract base class for generators of FilterBankEvent's.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.
Serialization FormatFirst, be sure to get a good overview of the LoadSave style. Most serialization is handled using this interface. When, for instance, RawCameraGenerator::saveBuffer() is called, it first calls it's super class, FilterBankGenerator::saveBuffer(), which will write out the general image information, common to all subclasses of FilterBankGenerator. (i'll cover the specifics in a second) Once that's done, the RawCameraGenerator adds it's own bit of header and then saves the image data itself. Note that only a single channel is being saved at this point. So for instance, all the Y information. No interleaving is going on. (unless you're saving from InterleavedYUVGenerator of course, which treats the 3 interleaved channels as a single image) Otherwise,only one image (selected with selectSaveImage()) of the bank will loaded or saved at a time.
So, anyway. The first header will be the same for all FilterBankGenerator subclasses. In the specification below, I'm going to use one field per line (the new lines are not literal, it's a binary stream). Each field is of the form '< FilterBankGenerator Header: (from FilterBankGenerator::saveBuffer())
Generator Specific Header (selected examples follow, or similarly, any of the other generators)
However, while we're on the topic, I'll mention that although this is the same image format used for streaming to VisionGUI, there's a few more fields added by RawCamBehavior or SegCamBehavior at the beginning of each packet. See those classes for more information on the wireless protocol. That should tell you everything you need to know to interpret the vision stream as well.
Adding New FilterBankGenerator SubclassesIf 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. If you want to be able to transmit or save your images, you will need to override the LoadSave functions (listed below) to provide your own code for interpreting the image data itself, and then create or modify a behavior to open a socket and transmit the information. (you could do that from within the generator itself if you like) You will probably also want to add a few extra functions to allow users to set compression/data format parameters.
Definition at line 112 of file FilterBankGenerator.h.
Constructor & Destructor Documentation
destructor
Your own subclasses should also have destructors which call freeCaches() and destruct(). Otherwise, if you override these functions to delete any custom memory you allocate, those implementations won't be called by this destructor... a destructor ignores virtual functions, only calls at its own class level. Definition at line 128 of file FilterBankGenerator.h.
Member Function Documentation
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 Implemented in BufferedImageGenerator, CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, PNGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator. Referenced by getImage().
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 Implemented in BufferedImageGenerator, CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, PNGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator. Referenced by getImage().
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 BufferedImageGenerator, CDTGenerator, InterleavedYUVGenerator, RawCameraGenerator, and RegionGenerator. Definition at line 26 of file FilterBankGenerator.cc. Referenced by RegionGenerator::freeCaches(), RawCameraGenerator::freeCaches(), InterleavedYUVGenerator::freeCaches(), CDTGenerator::freeCaches(), setNumImages(), ~FilterBankGenerator(), JPEGGenerator::~JPEGGenerator(), PNGGenerator::~PNGGenerator(), RLEGenerator::~RLEGenerator(), and SegmentedColorGenerator::~SegmentedColorGenerator().
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.
Implements LoadSave. Reimplemented in BufferedImageGenerator, CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, PNGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator. Definition at line 57 of file FilterBankGenerator.cc. Referenced by SegmentedColorGenerator::getBinSize(), RLEGenerator::getBinSize(), RegionGenerator::getBinSize(), RawCameraGenerator::getBinSize(), PNGGenerator::getBinSize(), JPEGGenerator::getBinSize(), InterleavedYUVGenerator::getBinSize(), CDTGenerator::getBinSize(), and RawCameraGenerator::saveFileStream().
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 12 of file FilterBankGenerator.cc. Referenced by SegmentedColorGenerator::calcImage(), RLEGenerator::calcImage(), RegionGenerator::calcImage(), PNGGenerator::calcImage(), JPEGGenerator::calcImage(), InterleavedYUVGenerator::calcImage(), InterleavedYUVGenerator::createImageCache(), FilterBankEvent::getImage(), RLEGenerator::getNumRuns(), getPixel(), RLEGenerator::getRun(), RLEGenerator::getRuns(), PNGGenerator::loadBuffer(), JPEGGenerator::loadBuffer(), RawCameraGenerator::reconstructImage(), selectSaveImage(), Graphics::updateFBG(), LGmixin::uploadCameraImage(), and RawCameraGenerator::upsampleImage().
returns whether or not an image has already been calculated for the current frame If you call this immediately after getImage() and this still returns false, then an error must have occurred during processing Definition at line 149 of file FilterBankGenerator.h.
returns a pointer to a particular sample; if you are using this in an inner loop, consider using the getSkip() and getIncrement() values to iterate with better performance
Definition at line 188 of file FilterBankGenerator.h.
returns a pointer to a particular sample; if you are using this in an inner loop, consider using the getSkip() and getIncrement() values to iterate with better performance
Definition at line 178 of file FilterBankGenerator.h. Referenced by getPixel().
sets the pixel-coordinate px and py parameters to the corresponding value of x and y
Definition at line 203 of file FilterBankGenerator.h. Referenced by getPixel(), and Graphics::getPixelCoordinates().
sets the x and y parameters from the pixel-coordinates px and py
Definition at line 219 of file FilterBankGenerator.h. Referenced by Graphics::getRealCoordinates().
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 162 of file FilterBankGenerator.h. Referenced by SegmentedColorGenerator::calcImage(), RawCameraGenerator::calcImage(), InterleavedYUVGenerator::createImageCache(), getPixel(), FilterBankEvent::getStride(), RawCameraGenerator::saveBuffer(), RawCameraGenerator::saveFileStream(), and Graphics::updateFBG().
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 in BufferedImageGenerator, and InterleavedYUVGenerator. Definition at line 36 of file FilterBankGenerator.cc. Referenced by freeCaches(), RawCameraGenerator::processEvent(), CDTGenerator::processEvent(), refresh(), 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 BufferedImageGenerator, CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, PNGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator. Definition at line 68 of file FilterBankGenerator.cc. Referenced by SegmentedColorGenerator::loadBuffer(), RLEGenerator::loadBuffer(), RegionGenerator::loadBuffer(), RawCameraGenerator::loadBuffer(), PNGGenerator::loadBuffer(), JPEGGenerator::loadBuffer(), and InterleavedYUVGenerator::loadBuffer().
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 Reimplemented from EventGeneratorBase. Reimplemented in BufferedImageGenerator, CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, PNGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator. Definition at line 43 of file FilterBankGenerator.cc. Referenced by SegmentedColorGenerator::processEvent(), RLEGenerator::processEvent(), RegionGenerator::processEvent(), PNGGenerator::processEvent(), JPEGGenerator::processEvent(), and InterleavedYUVGenerator::processEvent().
updates the image data to make sure its up to date with what's available from the source If someone calls getImage on a stage which hadn't been listening for events (an optimization to save time when it doesn't have any listeners of its own -- see EventGeneratorBase), then this will retroactively pull image data from the source even though the event for it was missed
Definition at line 158 of file FilterBankGenerator.cc. Referenced by getImage(), processEvent(), and refresh().
Save to a given buffer in memory.
Implements LoadSave. Reimplemented in BufferedImageGenerator, CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, PNGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator. Definition at line 78 of file FilterBankGenerator.cc. Referenced by SegmentedColorGenerator::saveBuffer(), RLEGenerator::saveBuffer(), RegionGenerator::saveBuffer(), RawCameraGenerator::saveBuffer(), PNGGenerator::saveBuffer(), JPEGGenerator::saveBuffer(), InterleavedYUVGenerator::saveBuffer(), CDTGenerator::saveBuffer(), RawCameraGenerator::saveFileStream(), and SegCamBehavior::writeSeg().
Not actually part of the LoadSave interface, but allows you to select which image of the bank will be saved. Calling this will also cause the image data for that image to be calculated, otherwise saveBuffer won't have up-to-date data to save. When loading, the saved image's layer and channel will reset this Definition at line 258 of file FilterBankGenerator.h. Referenced by RegionCamBehavior::writeRegions(), SegCamBehavior::writeRLE(), and SegCamBehavior::writeSeg().
resets width and height parameters to that of the src You'll probably want to override this to also set skips and strides Reimplemented in BufferedImageGenerator, CDTGenerator, InterleavedYUVGenerator, RawCameraGenerator, RLEGenerator, and SegmentedColorGenerator. Definition at line 126 of file FilterBankGenerator.cc. Referenced by refresh(), SegmentedColorGenerator::setDimensions(), RLEGenerator::setDimensions(), and InterleavedYUVGenerator::setDimensions().
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 in BufferedImageGenerator, CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, PNGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator. Definition at line 89 of file FilterBankGenerator.cc. Referenced by FilterBankGenerator(), refresh(), SegmentedColorGenerator::setNumImages(), RLEGenerator::setNumImages(), RegionGenerator::setNumImages(), RawCameraGenerator::setNumImages(), PNGGenerator::setNumImages(), JPEGGenerator::setNumImages(), InterleavedYUVGenerator::setNumImages(), and CDTGenerator::setNumImages().
Member Data Documentation
the frame number of last frame received by processEvent - subclasses will need to set to the source's frameNumber if they don't call FilterBankGenerator::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 (when running on the aibo), so there's no way they can be processed. Definition at line 375 of file FilterBankGenerator.h. Referenced by getFrameNumber(), RawCameraGenerator::processEvent(), CDTGenerator::processEvent(), and refresh().
subclasses should increment this any time they make a new filter bank available this is automatically incremented if you use the FilterBankGenerator::processEvent() Definition at line 382 of file FilterBankGenerator.h. Referenced by getFramesProcessed(), RawCameraGenerator::processEvent(), CDTGenerator::processEvent(), and refresh().
The documentation for this class was generated from the following files: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Tekkotsu v3.0 |
Generated Fri May 11 20:08:10 2007 by Doxygen 1.4.7 |