00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00029
00030 class IntegralEdgesOriExtraction : public VisualFeaturesExtraction<double>
00031 {
00032 public:
00033
00034
00035
00036 IntegralEdgesOriExtraction();
00037
00038
00039
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
00048
00049 IntegralEdgesOriExtraction(std::string nodeName, FD::ParameterSet params);
00050
00051
00052
00053
00054 IntegralEdgesOriExtraction(std::istream &in)
00055 {
00056 readFrom(in);
00057 }
00058
00059 virtual ~IntegralEdgesOriExtraction();
00060
00061
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
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
00115 int m_imageInID;
00116 int m_roiInID;
00117 int m_useNextImgInID;
00118
00119
00120 int m_featuresOutID;
00121 int m_ppCompletedOutID;
00122
00123
00124 int m_width;
00125 int m_imgSumWidth;
00126
00127 int m_height;
00128
00129 int m_numChannels;
00130
00131 int m_numPixels;
00132
00133 int m_numBytesInFrame;
00134
00135 int m_numOriBins;
00136
00137
00138 int m_numHoriIntRect;
00139 int m_numVertIntRect;
00140 int m_numIntRect;
00141
00142 double m_edgesStrTresh;
00143
00144 double m_maxStrengthValue;
00145 double m_maxFeatValue;
00146
00147 bool m_useRectDiff;
00148 double *m_tmpMeanFeatures;
00149 double *m_curMeanVal;
00150
00151
00152 FD::RCPtr<FD::Vector<VisualFeatureDesc<double> *> > m_featVect;
00153
00154
00155 IplImage *m_curImage;
00156
00157 IplImage *m_grayImage;
00158
00159 IplImage *m_oriXImage;
00160
00161 IplImage *m_oriYImage;
00162
00163 IplImage **m_edgesOri;
00164
00165 IplImage **m_edgesOriSum;
00166
00167 FD::ObjectRef m_edgesOriSumRef;
00168
00169
00170 float **m_edgesOriPix;
00171 double **m_edgesOriSumPix;
00172 };
00173
00174 }
00175
00176 #endif