Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
RawCameraGenerator.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_RawCameraGenerator_h_ 00003 #define INCLUDED_RawCameraGenerator_h_ 00004 00005 #include "Vision/FilterBankGenerator.h" 00006 00007 class OFbkImageVectorData; 00008 class OFbkImageInfo; 00009 00010 //! Generates FilterBankEvents containing raw camera images directly from the system (doesn't make a copy) 00011 class RawCameraGenerator : public FilterBankGenerator { 00012 public: 00013 //! constructor, numRawLayers is the number of real layers passed from the system, numCalcLayers is the total number of layers to make available 00014 /*! The extra calculated layers are simply created by giving larger 00015 * increments, they reference the same data (no computational cost, 00016 * marginal memory costs... it's just nice to have more layers in 00017 * the image pyramid. 00018 * 00019 * However you'll have to write your code to use the getIncrement() 00020 * value properly if you want it to work. Otherwise, you could 00021 * write a de-interlace generator which will do the resampling. 00022 * 00023 * The top most layer (largest index) is a double-scale image. For 00024 * the Y-channel, it is reconstructed from the 4 Y channels. For 00025 * the other channels, it just does a fast scaling (but these 00026 * operations do cost, so use the top layer conservatively. 00027 * 00028 * @see FilterBankGenerator for information on serialization format 00029 */ 00030 RawCameraGenerator(unsigned int numRawLayers, unsigned int numCalcLayers, EventBase::EventGeneratorID_t gid, unsigned int sid, unsigned int mysid); 00031 00032 //! destructor 00033 virtual ~RawCameraGenerator() { 00034 freeCaches(); 00035 destruct(); 00036 } 00037 00038 static std::string getClassDescription() { return "Translates OFbkImageVectorData objects from the system into a slightly more accessible FilterBankEvent for further processing"; } 00039 00040 //! holds id values for specifying image channel/bands 00041 enum channel_id_t { 00042 CHAN_Y, //!< Y (intensity) channel 00043 CHAN_U, //!< Cr (approx. pink,red,yellow) channel 00044 CHAN_V, //!< Cb (approx. blue,green,yellow) channel 00045 CHAN_Y_DY, //!< vertical derivative of Y channel (aka LH) 00046 CHAN_Y_DX, //!< horizontal derivative of Y channel (aka HL) 00047 CHAN_Y_DXDY, //!< vert. & horiz. derivatives of Y channel (aka HH) 00048 NUM_CHANNELS //!< number of channels per resolution layer 00049 }; 00050 00051 //! called with system's image info 00052 virtual void processEvent(const EventBase& event); 00053 00054 //! 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 00055 virtual void freeCaches(); 00056 00057 virtual unsigned int getBinSize() const; 00058 00059 virtual unsigned int LoadBuffer(const char buf[], unsigned int len); 00060 00061 virtual unsigned int SaveBuffer(char buf[], unsigned int len) const; 00062 00063 virtual unsigned int SaveFileStream(FILE* f) const; //!< overrridden to allow saving direct to file without an extra buffer copy 00064 00065 protected: 00066 //! ohh, this is so yucky. But we need to get around heap allocation bugs with large regions in Aperios :( 00067 /*! So we store the double size images statically within the class. 00068 * What a waste of memory since we're probably not using these very 00069 * much, and they are rather large... :( 00070 * 00071 * The 2.0 release had the proper dynamic allocation 00072 * implementation, but has been replaced in 2.0.1 with this static 00073 * allocation so it won't crash. 00074 * 00075 * Of course, if the memory allocation bug is never fixed, and 00076 * camera sizes increase in later models, this will have to be 00077 * modified. */ 00078 unsigned char dblRes[NUM_CHANNELS][416][320]; 00079 00080 virtual void setNumImages(unsigned int nLayers, unsigned int nChannels); 00081 00082 virtual void setDimensions(); //!< resets the width, height, skip and stride values 00083 virtual unsigned char * createImageCache(unsigned int layer, unsigned int chan) const; 00084 virtual void calcImage(unsigned int layer, unsigned int chan) const; 00085 virtual void destruct(); 00086 00087 //! returns the value to pass to OPENR functions corresponding to the desired channel_id_t. 00088 inline static unsigned int mapChannelID(channel_id_t chan); 00089 00090 //! Creates a double resolution version of a channel, doesn't do any smoothing 00091 void upsampleImage(channel_id_t chan) const; 00092 00093 //! Creates a double resolution Y-channel from the Y and Y gradient channels 00094 void reconstructImage() const; 00095 00096 //! helper functions for reconstructImage() - see documentation for that function 00097 static inline unsigned char clipRange(int val) { 00098 if (val < 0) { return 0; } 00099 else if (val > 255) { return 255; } 00100 else { return (unsigned char)val; } 00101 } 00102 00103 unsigned int numRealLayers; //!< the number of "real" layers being sent from the system 00104 00105 unsigned char ** layers; //!< points to the image data supplied by the system, one per layer (all channels are interleaved by row) 00106 const OFbkImageInfo ** imageInfos; //!< image info provided by the system 00107 00108 private: 00109 RawCameraGenerator(const RawCameraGenerator& fbk); //!< don't call 00110 const RawCameraGenerator& operator=(const RawCameraGenerator& fbk); //!< don't call 00111 }; 00112 00113 /*! @file 00114 * @brief Describes RawCameraGenerator, which generates FilterBankEvents containing raw camera images 00115 * @author ejt (Creator) 00116 * 00117 * $Author: ejt $ 00118 * $Name: tekkotsu-2_1 $ 00119 * $Revision: 1.14 $ 00120 * $State: Exp $ 00121 * $Date: 2004/02/18 21:13:32 $ 00122 */ 00123 00124 #endif |
Tekkotsu v2.1 |
Generated Tue Mar 16 23:19:15 2004 by Doxygen 1.3.5 |