Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

RawCameraGenerator Class Reference

#include <RawCameraGenerator.h>

Inheritance diagram for RawCameraGenerator:

List of all members.


Detailed Description

Generates FilterBankEvents containing raw camera images directly from the system (doesn't make a copy).

Definition at line 11 of file RawCameraGenerator.h.


Public Types

enum  channel_id_t {
  CHAN_Y, CHAN_U, CHAN_V, CHAN_Y_DY,
  CHAN_Y_DX, CHAN_Y_DXDY, NUM_CHANNELS
}
 holds id values for specifying image channel/bands More...

Public Member Functions

 RawCameraGenerator (unsigned int numRawLayers, unsigned int numCalcLayers, unsigned int mysid, EventBase::EventGeneratorID_t gid, unsigned int sid)
 constructor, numRawLayers is the number of real layers passed from the system, numCalcLayers is the total number of layers to make available
virtual ~RawCameraGenerator ()
 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)
 called with system's image info
virtual void freeCaches ()
 the memory for all layers except the double layer was allocated by system, so we just set them to NULL before calling FilterBankGenerator::freeCaches() so it won't try to delete them
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

Static Public Member Functions

static std::string getClassDescription ()
 Gives a short description of what this class of behaviors does... you should override this (but don't have to).

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 the width, height, skip and stride values
virtual unsigned char * createImageCache (unsigned int layer, unsigned int chan) 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 chan)
 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 destruct ()
 deletes the arrays
void upsampleImage (channel_id_t chan)
 Creates a double resolution version of a channel, doesn't do any smoothing.
void reconstructImage ()
 Creates a double resolution Y-channel from the Y and Y gradient channels.

Static Protected Member Functions

static unsigned int mapChannelID (channel_id_t chan)
 returns the value to pass to OPENR functions corresponding to the desired channel_id_t.
static unsigned char clipRange (int val)
 helper functions for reconstructImage() - see documentation for that function

Protected Attributes

unsigned char dblRes [NUM_CHANNELS][CameraResolutionX *2][CameraResolutionY *2]
 ohh, this is so yucky. But we need to get around heap allocation bugs with large regions in Aperios :(
unsigned int numRealLayers
 the number of "real" layers being sent from the system
unsigned char ** layers
 points to the image data supplied by the system, one per layer (all channels are interleaved by row)
const OFbkImageInfo ** imageInfos
 image info provided by the system

Private Member Functions

 RawCameraGenerator (const RawCameraGenerator &fbk)
 don't call
const RawCameraGeneratoroperator= (const RawCameraGenerator &fbk)
 don't call

Member Enumeration Documentation

holds id values for specifying image channel/bands

Enumerator:
CHAN_Y  Y (intensity) channel.
CHAN_U  Cb (approx. blue,green,yellow) channel.
CHAN_V  Cr (approx. pink,red,yellow) channel.
CHAN_Y_DY  vertical derivative of Y channel (aka LH)
CHAN_Y_DX  horizontal derivative of Y channel (aka HL)
CHAN_Y_DXDY  vert. & horiz. derivatives of Y channel (aka HH)
NUM_CHANNELS  number of channels per resolution layer

Definition at line 41 of file RawCameraGenerator.h.


Constructor & Destructor Documentation

RawCameraGenerator::RawCameraGenerator ( unsigned int  numRawLayers,
unsigned int  numCalcLayers,
unsigned int  mysid,
EventBase::EventGeneratorID_t  gid,
unsigned int  sid 
)

constructor, numRawLayers is the number of real layers passed from the system, numCalcLayers is the total number of layers to make available

The extra calculated layers are simply created by giving larger increments, they reference the same data (no computational cost, marginal memory costs... it's just nice to have more layers in the image pyramid.

However you'll have to write your code to use the getIncrement() value properly if you want it to work. Otherwise, you could write a de-interlace generator which will do the resampling.

The top most layer (largest index) is a double-scale image. For the Y-channel, it is reconstructed from the 4 Y channels. For the other channels, it just does a fast scaling (but these operations do cost, so use the top layer conservatively.

See also:
FilterBankGenerator for information on serialization format

Definition at line 17 of file RawCameraGenerator.cc.

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

destructor

Definition at line 33 of file RawCameraGenerator.h.

RawCameraGenerator::RawCameraGenerator ( const RawCameraGenerator fbk  )  [private]

don't call


Member Function Documentation

static std::string RawCameraGenerator::getClassDescription (  )  [inline, static]

Gives a short description of what this class of behaviors does... you should override this (but don't have to).

If you do override this, also consider overriding getDescription() to return it

Reimplemented from BehaviorBase.

Definition at line 38 of file RawCameraGenerator.h.

virtual void RawCameraGenerator::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 52 of file RawCameraGenerator.h.

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

called with system's image info

The const casts in this function are regretable but necessary since the OPEN-R OFbkImage constructor requires mutable arguments, even though it shouldn't be modifying the data

Reimplemented from FilterBankGenerator.

Definition at line 35 of file RawCameraGenerator.cc.

void RawCameraGenerator::freeCaches (  )  [virtual]

the memory for all layers except the double layer was allocated by system, so we just set them to NULL before calling FilterBankGenerator::freeCaches() so it won't try to delete them

Reimplemented from FilterBankGenerator.

Definition at line 260 of file RawCameraGenerator.cc.

Referenced by processEvent(), setDimensions(), and ~RawCameraGenerator().

unsigned int RawCameraGenerator::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 102 of file RawCameraGenerator.cc.

unsigned int RawCameraGenerator::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 110 of file RawCameraGenerator.cc.

unsigned int RawCameraGenerator::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 135 of file RawCameraGenerator.cc.

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

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

Reimplemented from LoadSave.

Definition at line 176 of file RawCameraGenerator.cc.

void RawCameraGenerator::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 271 of file RawCameraGenerator.cc.

Referenced by RawCameraGenerator().

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

resets the width, height, skip and stride values

Reimplemented from FilterBankGenerator.

Definition at line 245 of file RawCameraGenerator.cc.

Referenced by processEvent().

unsigned char * RawCameraGenerator::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 287 of file RawCameraGenerator.cc.

Referenced by loadBuffer().

void RawCameraGenerator::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 295 of file RawCameraGenerator.cc.

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

deletes the arrays

Reimplemented from FilterBankGenerator.

Definition at line 351 of file RawCameraGenerator.cc.

Referenced by ~RawCameraGenerator().

unsigned int RawCameraGenerator::mapChannelID ( channel_id_t  chan  )  [inline, static, protected]

returns the value to pass to OPENR functions corresponding to the desired channel_id_t.

Definition at line 360 of file RawCameraGenerator.cc.

Referenced by calcImage().

void RawCameraGenerator::upsampleImage ( channel_id_t  chan  )  [protected]

Creates a double resolution version of a channel, doesn't do any smoothing.

Definition at line 381 of file RawCameraGenerator.cc.

Referenced by calcImage().

void RawCameraGenerator::reconstructImage (  )  [protected]

Creates a double resolution Y-channel from the Y and Y gradient channels.

This function is lifted from Sony's ImageObserver sample code. Here's Sony's original license for the file (ImageObserver.cc) that contained this function:

	  Copyright 2002,2003 Sony Corporation

		Permission to use, copy, modify, and redistribute this software for
		non-commercial use is hereby granted.

		This software is provided "as is" without warranty of any kind,
		either expressed or implied, including but not limited to the
		implied warranties of fitness for a particular purpose.
		

Definition at line 422 of file RawCameraGenerator.cc.

Referenced by calcImage().

static unsigned char RawCameraGenerator::clipRange ( int  val  )  [inline, static, protected]

helper functions for reconstructImage() - see documentation for that function

Definition at line 96 of file RawCameraGenerator.h.

Referenced by reconstructImage().

const RawCameraGenerator& RawCameraGenerator::operator= ( const RawCameraGenerator fbk  )  [private]

don't call


Member Data Documentation

unsigned char RawCameraGenerator::dblRes[NUM_CHANNELS][CameraResolutionX *2][CameraResolutionY *2] [protected]

ohh, this is so yucky. But we need to get around heap allocation bugs with large regions in Aperios :(

So we store the double size images statically within the class. What a waste of memory since we're probably not using these very much, and they are rather large... :(

The 2.0 release had the proper dynamic allocation implementation, but has been replaced in 2.0.1 with this static allocation so it won't crash.

Definition at line 77 of file RawCameraGenerator.h.

Referenced by createImageCache().

unsigned int RawCameraGenerator::numRealLayers [protected]

the number of "real" layers being sent from the system

Definition at line 102 of file RawCameraGenerator.h.

Referenced by calcImage(), processEvent(), setDimensions(), and setNumImages().

unsigned char** RawCameraGenerator::layers [protected]

points to the image data supplied by the system, one per layer (all channels are interleaved by row)

Definition at line 104 of file RawCameraGenerator.h.

Referenced by calcImage(), destruct(), processEvent(), and setNumImages().

image info provided by the system

Definition at line 105 of file RawCameraGenerator.h.

Referenced by calcImage(), destruct(), processEvent(), setDimensions(), and setNumImages().


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

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