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

IntegralEdgesOriExtraction.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 _INTEGRALEDGESORIEXTRACTION_H_
00018 #define _INTEGRALEDGESORIEXTRACTION_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 Edges Orientation Features Extraction for RobotFlow 
00029 //
00030 class IntegralEdgesOriExtraction : public VisualFeaturesExtraction<double>
00031 { 
00032 public:
00033         //
00034         // Default constructor for Object 
00035         //
00036         IntegralEdgesOriExtraction();
00037         
00038         //
00039         // Constructor with complete intialisation
00040         //
00041         IntegralEdgesOriExtraction(int i_width, int i_height, 
00042                 int i_numChannels, int i_numHoriIntRect, int i_numVertIntRect,
00043                 int i_numOriBins, double i_edgesStrTresh,
00044                 double i_maxStrengthValue, bool i_useRectDiff);
00045 
00046         //
00047         // BufferedNode constructor
00048         //
00049         IntegralEdgesOriExtraction(std::string nodeName, FD::ParameterSet params);
00050 
00051         //
00052         // Constructor using input stream
00053         //
00054         IntegralEdgesOriExtraction(std::istream &in)
00055         {
00056                 readFrom(in);
00057         }
00058         
00059         virtual ~IntegralEdgesOriExtraction();
00060         
00061         // Default routine to print a IntegralEdgesOriExtraction object to an output stream
00062         void printOn(std::ostream &out) const
00063         {
00064                 throw new FD::GeneralException("Exception in IntegralEdgesOriExtraction::printOn: method not yet implemented.",__FILE__,__LINE__);
00065         }
00066 
00067         // Default routine to read a IntegralEdgesOriExtraction object from an input stream
00068         void readFrom(std::istream &in)
00069         {
00070                 throw new FD::GeneralException("Exception in IntegralEdgesOriExtraction::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 ExtractFeatures(VisualROI *i_roi);
00080         
00081         void ExtractFeatures(IplImage *i_input, VisualROI *i_roi);
00082         
00083         VisualFeatureDesc<double> *GetDescriptor()
00084         {
00085                 return (*m_featVect)[0];
00086         }
00087         
00088         const VisualFeatureDesc<double> *GetCstDescriptor() const
00089         {
00090                 return (const VisualIntegralDesc<double> *)(*m_featVect)[0];
00091         }
00092         
00093         FD::ObjectRef GetEdgesOriSumRef() 
00094         {
00095                 return m_edgesOriSumRef;
00096         }
00097         
00098         void SetEdgesOriSumRef(FD::ObjectRef i_ref) 
00099         {
00100                 m_edgesOriSumRef = i_ref;
00101                 
00102                 if (!m_edgesOriSumRef->isNil()) {
00103                         FD::RCPtr<FD::Vector<double *> > imgVecRef = m_edgesOriSumRef;
00104                         if (imgVecRef->size() != m_numOriBins) {
00105                                 throw new FD::GeneralException("Exception in IntegralEdgesOriExtraction::SetEdgesOriSumRef: given reference does not seem to have the same number of orientations.",__FILE__,__LINE__);
00106                         }
00107                 }
00108         }
00109 
00110 private:
00111         void Initialize();
00112 
00113 private:
00114         // Input IDs (for BufferedNode)
00115         int m_imageInID;
00116         int m_roiInID;
00117         int m_useNextImgInID;
00118         
00119         // Output IDs (for BufferedNode)
00120         int m_featuresOutID;
00121         int m_ppCompletedOutID;
00122         
00123         // Width of images
00124         int m_width;
00125         int m_imgSumWidth;
00126         // Height of images
00127         int m_height;
00128         // Number of channels in an image
00129         int m_numChannels;
00130         // Number of pixels in an image
00131         int m_numPixels;
00132         // Number of bytes in an image
00133         int m_numBytesInFrame;
00134         // Number of orientations to use
00135         int m_numOriBins;
00136         // Number of independant rectangular region to compute
00137         // the integral edges orientation features
00138         int m_numHoriIntRect;
00139         int m_numVertIntRect;
00140         int m_numIntRect;
00141         // Edge strength threshold to remove noisy edges
00142         double m_edgesStrTresh;
00143         // Maximum strength channel value
00144         double m_maxStrengthValue;
00145         double m_maxFeatValue;
00146         
00147         bool m_useRectDiff;
00148         double *m_tmpMeanFeatures;
00149         double *m_curMeanVal;
00150         
00151         // Integral color descriptor for region of interest
00152         FD::RCPtr<FD::Vector<VisualFeatureDesc<double> *> > m_featVect;
00153         
00154         // Temporary image copy
00155         IplImage *m_curImage;
00156         // Grayscale version of current image
00157         IplImage *m_grayImage;
00158         // Result from filtering With Sobel (X)
00159         IplImage *m_oriXImage;
00160         // Result from filtering With Sobel (Y)
00161         IplImage *m_oriYImage;
00162         // Multi-channel edges orientation map
00163         IplImage **m_edgesOri;
00164         // Multi-channel sum of edges orientation map
00165         IplImage **m_edgesOriSum;
00166         
00167         FD::ObjectRef m_edgesOriSumRef;
00168         
00169         // Pixel/value pointers
00170         float **m_edgesOriPix;
00171         double **m_edgesOriSumPix;
00172 };
00173 
00174 }
00175 
00176 #endif

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