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

ColorHistExtraction.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 _COLORHISTEXTRACTION_H_
00018 #define _COLORHISTEXTRACTION_H_
00019 
00020 #include "VisualFeaturesExtraction.h"
00021 #include "VisualHistogramDesc.h"
00022 #include "VisualTarget.h"
00023 #include <stdlib.h>
00024 #include <sys/timeb.h>
00025 
00026 namespace RobotFlow {
00027 //
00028 // Color histogram Features Extraction for RobotFlow 
00029 //
00030 class ColorHistExtraction : public VisualFeaturesExtraction<double>
00031 { 
00032 public:
00033         //
00034         // Default constructor for Object 
00035         //
00036         ColorHistExtraction();
00037         
00038         //
00039         // Constructor with complete intialisation
00040         //
00041         ColorHistExtraction(int i_width, int i_height, 
00042                 int i_numChannels, const FD::Vector<int> *i_numBins);
00043 
00044         //
00045         // Copy constructor
00046         //
00047         ColorHistExtraction(const ColorHistExtraction& i_ref);
00048 
00049         //
00050         // BufferedNode constructor
00051         //
00052         ColorHistExtraction(std::string nodeName, FD::ParameterSet params);
00053 
00054         //
00055         // Constructor using input stream
00056         //
00057         ColorHistExtraction(std::istream &in)
00058         {
00059                 readFrom(in);
00060         }
00061         
00062         virtual ~ColorHistExtraction();
00063         
00064         // Default routine to print a ColorHistExtraction object to an output stream
00065         void printOn(std::ostream &out) const
00066         {
00067                 throw new FD::GeneralException("Exception in ColorHistExtraction::printOn: method not yet implemented.",__FILE__,__LINE__);
00068         }
00069 
00070         // Default routine to read a ColorHistExtraction object from an input stream
00071         void readFrom(std::istream &in)
00072         {
00073                 throw new FD::GeneralException("Exception in ColorHistExtraction::readFrom: method not yet implemented.",__FILE__,__LINE__);
00074         }
00075         
00076         virtual void request(int output_id, const FD::ParameterSet &req);
00077         
00078         void calculate(int output_id, int count, FD::Buffer &out);
00079         
00080         void ExtractFeatures(VisualROI *i_roi);
00081         
00082         void ExtractFeatures(IplImage *i_input, VisualROI *i_roi);
00083         
00084         void EstimateMSLocation(const VisualTarget<double> *i_targetRef, 
00085                 int i_descIdx, FD::Vector<double> *o_msLocVec);
00086         
00087         VisualFeatureDesc<double> *GetDescriptor()
00088         {
00089                 return m_colorHistogram;
00090         }
00091         
00092         const VisualFeatureDesc<double> *GetCstDescriptor() const
00093         {
00094                 return (const VisualHistogramDesc<double, unsigned char> *)m_colorHistogram;
00095         }
00096 
00097 private:
00098         void Initialize(const FD::Vector<int> *i_numBins);
00099 
00100 private:
00101         // Input IDs (for BufferedNode)
00102         int m_imageInID;
00103         int m_numBinsInID;
00104         int m_roiInID;
00105         int m_targetInID;
00106         int m_targetDescIdxInID;
00107         int m_useNextImgInID;
00108         
00109         // Output IDs (for BufferedNode)
00110         int m_featuresOutID;
00111         int m_msLocOutID;
00112         int m_ppCompletedOutID;
00113         
00114         // Width of images
00115         int m_width;
00116         // Height of images
00117         int m_height;
00118         // Number of channels in an image
00119         int m_numChannels;
00120         // Number of pixels in an image
00121         int m_numPixels;
00122         // Number of bytes in an image
00123         int m_numBytesInFrame;
00124         
00125         // Initialization flag
00126         bool m_init;
00127         
00128         // Histogram descriptor for region of interest
00129         VisualHistogramDesc<double, unsigned char> *m_colorHistogram; 
00130         
00131         // Function pointer to the appropriate private extraction routine
00132         void (ColorHistExtraction::*m_extractionFct)(unsigned char *);
00133         
00134         // Temporary image copy
00135         IplImage *m_curImage;
00136 };
00137 
00138 }
00139 
00140 #endif

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