Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

CDTGenerator.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_CDTGenerator_h_
00003 #define INCLUDED_CDTGenerator_h_
00004 
00005 #include "Vision/FilterBankGenerator.h"
00006 
00007 class OFbkImageInfo;
00008 
00009 //! Generates SegmentedColorFilterBankEvents with images provided from the system
00010 /*! The Aibo has hardware-level color segmentation based on
00011  *  rectangular regions of UV color space.  This less flexible than
00012  *  the CMVision segmentation routines, which allow arbitrary shapes
00013  *  in color space, but the CDT (Color Detection Table) implementation
00014  *  has the major advantage of being done in hardware.
00015  *
00016  *  This class doesn't do any processing of its own, it simply
00017  *  provides access to the CDT segmented images generated by the
00018  *  system.
00019  *  
00020  *  To use this, you will first have to send the system the color
00021  *  regions that define the CDT.  You'll need to look in the OPEN-R
00022  *  documentation regarding the OCdtVectorData data structure and the
00023  *  New/Set/DeleteCdtVectorData() functions.
00024  *  
00025  *  For now, the color information in the Segmented Color Events will
00026  *  be NULL, so you won't be able to connect it to the rest of the
00027  *  CMVision stages unless you fill it in.  Filling in the color
00028  *  information will require modifications of this source - I'm
00029  *  consciously cutting some corners to get this out the door sooner.
00030  *  Hopefully someone who needs this capability can pick up where I
00031  *  left off.  It would be nice if someone made a version of
00032  *  CMVision's .col file format which also held the CDT information so
00033  *  the whole thing could be set up with one file load.
00034  *
00035  *  Only the actual layers sent by the system will be referenced - no
00036  *  double resolution layer.  Much like RawCameraGenerator, the extra
00037  *  subsampled images are simply using a larger interleave value.  If
00038  *  you want the images in continuous memory, you'll need to pass this
00039  *  through a de-interleaver stage.
00040  *  
00041  *  Only one channel is available.
00042  */
00043 class CDTGenerator : public FilterBankGenerator {
00044 public:
00045   //!constructor
00046   CDTGenerator(unsigned int numRawLayers, unsigned int numCalcLayers, unsigned int mysid, EventBase::EventGeneratorID_t gid, unsigned int sid);
00047 
00048   //! destructor
00049   virtual ~CDTGenerator() {
00050     freeCaches();
00051     destruct();
00052   }
00053   
00054   static std::string getClassDescription() { return "Extracts the segmented image channel (CDT) from the system's OFbkImageVectorData"; }
00055 
00056   //! holds id values for specifying image channel/bands
00057   enum channel_id_t {
00058     CHAN_CDT,    //!< Color Detection Table, segmented image
00059     NUM_CHANNELS //!< number of channels per resolution layer
00060   };
00061 
00062   //! need to override EventGeneratorBase's lazy listening -- as a root stage, need to remember each frame, just in case it might be used
00063   virtual void doStart() { FilterBankGenerator::doStart(); addSrcListener(); }
00064 
00065   //! called with system's image info
00066   virtual void doEvent();
00067   
00068   //! the memory for all layers was allocated by system, so we just set them to NULL before calling FilterBankGenerator::freeCaches() so it won't try to delete them
00069   virtual void freeCaches();
00070 
00071   virtual unsigned int getBinSize() const;
00072 
00073   virtual unsigned int loadBuffer(const char buf[], unsigned int len, const char* filename=NULL);
00074 
00075   virtual unsigned int saveBuffer(char buf[], unsigned int len) const;
00076 
00077 protected:
00078   virtual void setNumImages(unsigned int nLayers, unsigned int nChannels);
00079 
00080   //! resets the current width, height, stride, and skip for all of the layers
00081   virtual void setDimensions();
00082   
00083   virtual unsigned char * createImageCache(unsigned int layer, unsigned int chan) const;
00084   virtual void calcImage(unsigned int layer, unsigned int chan);
00085   virtual void destruct();
00086   
00087   unsigned int numRealLayers; //!< the number of actual layers to expect from the system
00088   
00089   unsigned char ** layers; //!< an array of pointers to actual system memory for each layer
00090   const OFbkImageInfo ** imageInfos; //!< information about image properties
00091 
00092 private:
00093   CDTGenerator(const CDTGenerator& fbk); //!< don't call
00094   const CDTGenerator& operator=(const CDTGenerator& fbk); //!< don't call
00095 };
00096 
00097 /*! @file 
00098  * @brief Describes CDTGenerator, which generates SegmentedColorFilterBankEvents with images provided from the system
00099  * @author ejt (Creator)
00100  */
00101 
00102 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:36 2016 by Doxygen 1.6.3