Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
#include <JPEGGenerator.h>
Inheritance diagram for JPEGGenerator:
There's only one channel per resolution layer, which holds the compressed data. This is mostly intended for being sent over wireless, but if you know how JPEG works, you may be able to interpret the compressed data directly and glean useful information from it. After all, compression is all about throwing away unimportant details and storing the salient information.
The generated events use 0 for their event source IDs. The row skip and row stride are 0. (they don't really apply here)
This can either compress a greyscale image or an interleaved YUV image. If the source generator's type is not InterleavedYUVGenerator, it will assume greyscale. Call setSource() to override this.
The InterleavedYUVGenerator is separated from this because it wouldn't really make things much faster to combine the algorithms, and others might find the interleaved format handy for passing to other libraries which expect that format, such as what happened with libjpeg.
Definition at line 35 of file JPEGGenerator.h.
Public Types | |
enum | src_mode_t { SRC_AUTO, SRC_GRAYSCALE, SRC_COLOR } |
Public Member Functions | |
JPEGGenerator (EventBase::EventGeneratorID_t gid, unsigned int sid, unsigned int mysid) | |
constructor | |
JPEGGenerator (EventBase::EventGeneratorID_t gid, unsigned int sid, unsigned int mysid, src_mode_t sMode) | |
constructor | |
virtual | ~JPEGGenerator () |
destructor | |
virtual void | setSourceMode (src_mode_t mode) |
set srcMode and curMode as well if mode==SRC_AUTO | |
virtual src_mode_t | getSourceMode () const |
returns srcMode | |
virtual src_mode_t | getCurrentSourceFormat () const |
returns curMode | |
virtual void | processEvent (const EventBase &event) |
should receive FilterBankEvents from a RawCameraGenerator (or a subclass thereof) | |
virtual unsigned int | getBinSize () const |
if we don't already know bytesUsed, let's assume the size will be smaller than the original uncompressed. If we fail this assumption, probably better to fail anyway. | |
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 unsigned int | getQuality () const |
returns quality | |
virtual void | setQuality (unsigned int q) |
sets quality; this will invalidate the cache if q does not equal current quality | |
virtual unsigned int | getImageSize (unsigned int layer, unsigned int chan) const |
returns the number of bytes used for the image returned by getImage() - will return 0 if the image hasn't been calculated yet (so call it after getImage()) | |
Static Public Member Functions | |
std::string | getClassDescription () |
Gives a short description of what this class of behaviors does... you should override this (but don't have to). | |
Static Public Attributes | |
const unsigned int | JPEG_HEADER_PAD = 500 |
add a bit to the expected size in getBinSize just to leave a little extra room for small images | |
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 void | setDimensions () |
resets width, height, skip and stride parameters | |
virtual unsigned char * | createImageCache (unsigned int layer, unsigned int chan) const |
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 chan) const |
virtual void | destruct () |
deletes the arrays | |
Protected Attributes | |
const FilterBankGenerator * | src |
the generator of the last FilterBankEvent received | |
src_mode_t | srcMode |
how to interpret source channel of next filter bank event | |
src_mode_t | curMode |
how to interpret getImage's current image | |
unsigned int ** | bytesUsed |
number of bytes used per image to actually store data; | |
jpeg_compress_struct | cinfo |
used to interface with libjpeg - holds compression parameters and state | |
jpeg_error_mgr | jerr |
used to interface with libjpeg - gives us access to error information | |
unsigned int | quality |
quality level to pass to libjpeg; -1U causes Config::vision_config::rawcam_compress_quality to be used | |
Private Member Functions | |
JPEGGenerator (const JPEGGenerator &fbk) | |
don't call | |
const JPEGGenerator & | operator= (const JPEGGenerator &fbk) |
don't call |
|
Definition at line 38 of file JPEGGenerator.h. Referenced by getCurrentSourceFormat(), and getSourceMode(). |
|
constructor
Definition at line 16 of file JPEGGenerator.cc. |
|
constructor
Definition at line 28 of file JPEGGenerator.cc. |
|
destructor
Definition at line 40 of file JPEGGenerator.cc. |
|
don't call
|
|
This function is taken pretty directly from the write_jpeg_mem() function from Sony's W3AIBO sample code. I have adapted it for this object, and added the ability to process greyscale images as well as color. Implements FilterBankGenerator. Definition at line 186 of file JPEGGenerator.cc. |
|
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 Implements FilterBankGenerator. Definition at line 175 of file JPEGGenerator.cc. Referenced by LoadBuffer(). |
|
deletes the arrays
Reimplemented from FilterBankGenerator. Definition at line 249 of file JPEGGenerator.cc. Referenced by ~JPEGGenerator(). |
|
if we don't already know bytesUsed, let's assume the size will be smaller than the original uncompressed. If we fail this assumption, probably better to fail anyway.
Reimplemented from FilterBankGenerator. Definition at line 75 of file JPEGGenerator.cc. |
|
Gives a short description of what this class of behaviors does... you should override this (but don't have to).
Reimplemented from BehaviorBase. Definition at line 59 of file JPEGGenerator.h. |
|
returns curMode
Definition at line 57 of file JPEGGenerator.h. Referenced by calcImage(), LoadBuffer(), SaveBuffer(), RawCamBehavior::writeColor(), and RawCamBehavior::writeSingleChannel(). |
|
returns the number of bytes used for the image returned by getImage() - will return 0 if the image hasn't been calculated yet (so call it after getImage())
Definition at line 82 of file JPEGGenerator.h. Referenced by CameraBehavior::processEvent(). |
|
returns quality
Definition at line 72 of file JPEGGenerator.h. Referenced by CameraBehavior::processEvent(). |
|
returns srcMode
Definition at line 55 of file JPEGGenerator.h. Referenced by processEvent(). |
|
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 JPEGGenerator.cc. |
|
don't call
|
|
should receive FilterBankEvents from a RawCameraGenerator (or a subclass thereof) The const casts in this function are regretable but necessary since the corresponding OPEN-R functions require mutable arguments, even though they shouldn't be modifying the data Reimplemented from FilterBankGenerator. Definition at line 52 of file JPEGGenerator.cc. |
|
Save to a given buffer.
Reimplemented from FilterBankGenerator. Definition at line 122 of file JPEGGenerator.cc. |
|
resets width, height, skip and stride parameters
Definition at line 154 of file JPEGGenerator.cc. Referenced by processEvent(). |
|
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 from FilterBankGenerator. Definition at line 163 of file JPEGGenerator.cc. Referenced by JPEGGenerator(), and processEvent(). |
|
sets quality; this will invalidate the cache if q does not equal current quality
Definition at line 74 of file JPEGGenerator.h. Referenced by CameraBehavior::processEvent(). |
|
set srcMode and curMode as well if mode==SRC_AUTO
Definition at line 53 of file JPEGGenerator.h. |
|
number of bytes used per image to actually store data;
Definition at line 95 of file JPEGGenerator.h. Referenced by calcImage(), destruct(), getBinSize(), getImageSize(), LoadBuffer(), SaveBuffer(), and setNumImages(). |
|
used to interface with libjpeg - holds compression parameters and state
Definition at line 97 of file JPEGGenerator.h. Referenced by calcImage(), JPEGGenerator(), and ~JPEGGenerator(). |
|
how to interpret getImage's current image
Definition at line 93 of file JPEGGenerator.h. Referenced by getCurrentSourceFormat(), processEvent(), and setSourceMode(). |
|
used to interface with libjpeg - gives us access to error information
Definition at line 98 of file JPEGGenerator.h. Referenced by JPEGGenerator(). |
|
add a bit to the expected size in getBinSize just to leave a little extra room for small images
Definition at line 37 of file JPEGGenerator.h. Referenced by calcImage(), createImageCache(), and getBinSize(). |
|
quality level to pass to libjpeg; -1U causes Config::vision_config::rawcam_compress_quality to be used
Definition at line 100 of file JPEGGenerator.h. Referenced by calcImage(), getQuality(), and setQuality(). |
|
the generator of the last FilterBankEvent received
Definition at line 91 of file JPEGGenerator.h. Referenced by calcImage(), processEvent(), and setDimensions(). |
|
how to interpret source channel of next filter bank event
Definition at line 92 of file JPEGGenerator.h. Referenced by getSourceMode(), and setSourceMode(). |
Tekkotsu v2.0 |
Generated Wed Jan 21 03:23:15 2004 by Doxygen 1.3.4 |