Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

IntegralColorExtraction.h

Go to the documentation of this file.
00001 /* Copyright (C) 2005 Pierre Moisan (Pierre.Moisan@USherbrooke.ca) 
00002 
00003    This library is free software; you can redistribute it and/or
00004    modify it under the terms of the GNU Lesser General Public
00005    License as published by the Free Software Foundation; either
00006    version 2.1 of the License, or (at your option) any later version.
00007    
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Lesser General Public License for more details.
00012    
00013    You should have received a copy of the GNU Lesser General Public
00014    License along with this library; if not, write to the Free Software
00015    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00016 */
00017 #ifndef _INTEGRALCOLOREXTRACTION_H_
00018 #define _INTEGRALCOLOREXTRACTION_H_
00019 
00020 #include "VisualFeaturesExtraction.h"
00021 #include "VisualIntegralDesc.h"
00022 #include "VisualTarget.h"
00023 #include <stdlib.h>
00024 #include <sys/timeb.h>
00025 
00026 namespace RobotFlow {
00027 //
00028 // Integral Color Features Extraction for RobotFlow 
00029 //
00030 class IntegralColorExtraction : public VisualFeaturesExtraction<double>
00031 { 
00032 public:
00033         //
00034         // Default constructor for Object 
00035         //
00036         IntegralColorExtraction();
00037         
00038         //
00039         // Constructor with complete intialisation
00040         //
00041         IntegralColorExtraction(int i_width, int i_height, 
00042                 int i_numChannels, int i_numHoriIntRect, int i_numVertIntRect,
00043                 double i_maxValue, bool i_useRectDiff, bool i_useBoundary, 
00044                 double i_boundaryMeanDiffThresh);
00045 
00046         //
00047         // BufferedNode constructor
00048         //
00049         IntegralColorExtraction(std::string nodeName, FD::ParameterSet params);
00050 
00051         //
00052         // Constructor using input stream
00053         //
00054         IntegralColorExtraction(std::istream &in)
00055         {
00056                 readFrom(in);
00057         }
00058         
00059         virtual ~IntegralColorExtraction();
00060         
00061         // Default routine to print a IntegralColorExtraction object to an output stream
00062         void printOn(std::ostream &out) const
00063         {
00064                 throw new FD::GeneralException("Exception in IntegralColorExtraction::printOn: method not yet implemented.",__FILE__,__LINE__);
00065         }
00066 
00067         // Default routine to read a IntegralColorExtraction object from an input stream
00068         void readFrom(std::istream &in)
00069         {
00070                 throw new FD::GeneralException("Exception in IntegralColorExtraction::readFrom: method not yet implemented.",__FILE__,__LINE__);
00071         }
00072         
00073         virtual void request(int output_id, const FD::ParameterSet &req);
00074         
00075         void calculate(int output_id, int count, FD::Buffer &out);
00076         
00077         void Preprocess(IplImage *i_srcImg);
00078         
00079         void Preprocess(const unsigned char *i_src);
00080         
00081         void ExtractFeatures(VisualROI *i_roi);
00082         
00083         void ExtractFeatures(IplImage *i_input, VisualROI *i_roi);
00084         
00085         VisualFeatureDesc<double> *GetDescriptor()
00086         {
00087                 return (*m_featVect)[0];
00088         }
00089         
00090         const VisualFeatureDesc<double> *GetCstDescriptor() const
00091         {
00092                 return (const VisualIntegralDesc<double> *)(*m_featVect)[0];
00093         }
00094 
00095 private:
00096         void Initialize();
00097 
00098 private:
00099         // Input IDs (for BufferedNode)
00100         int m_imageInID;
00101         int m_roiInID;
00102         int m_useNextImgInID;
00103         
00104         // Output IDs (for BufferedNode)
00105         int m_featuresOutID;
00106         int m_ppCompletedOutID;
00107         
00108         // Width of images
00109         int m_width;
00110         int m_imgSumWidth;
00111         // Height of images
00112         int m_height;
00113         // Number of channels in an image
00114         int m_numChannels;
00115         // Number of pixels in an image
00116         int m_numPixels;
00117         // Number of bytes in an image
00118         int m_numBytesInFrame;
00119         // Number of independant rectangular region to compute
00120         // the integral color features
00121         int m_numHoriIntRect;
00122         int m_numVertIntRect;
00123         int m_numIntRect;
00124         int m_numFeatures;
00125         // Maximum pixel channel value
00126         double m_maxValue;
00127         
00128         bool m_useRectDiff;
00129         double *m_tmpMeanFeatures;
00130         double *m_curMeanVal;
00131         
00132         bool m_useBoundary;
00133         double m_boundaryMeanDiffThresh;
00134         
00135         // Integral color descriptor for region of interest
00136         FD::RCPtr<FD::Vector<VisualFeatureDesc<double> *> > m_featVect;
00137         
00138         // Temporary image copy
00139         IplImage *m_curImage;
00140         // Each channel image
00141         IplImage **m_chImage;
00142         // Pointer to channel image pixels
00143         unsigned char **m_chPixPtr;
00144         int **m_sumPixPtr;
00145         // Sum of pixels (integral) image
00146         IplImage **m_sumImage;
00147 };
00148 
00149 }
00150 
00151 #endif

Generated on Wed Oct 5 14:36:12 2005 for RobotFlow by  doxygen 1.4.4