fixed compilation under ubuntu

This commit is contained in:
Anatoly Baksheev 2011-09-21 18:25:22 +00:00
parent 50543d627f
commit 25cadb1abd

View File

@ -238,84 +238,84 @@ inline void LBPEvaluator::Feature :: updatePtrs( const Mat& sum )
CV_SUM_PTRS( p[8], p[9], p[12], p[13], ptr, tr, step ); CV_SUM_PTRS( p[8], p[9], p[12], p[13], ptr, tr, step );
} }
//---------------------------------------------- HOGEvaluator ------------------------------------------- //---------------------------------------------- HOGEvaluator -------------------------------------------
class HOGEvaluator : public FeatureEvaluator class HOGEvaluator : public FeatureEvaluator
{ {
public: public:
struct Feature struct Feature
{ {
Feature(); Feature();
float calc( int offset ) const; float calc( int offset ) const;
void updatePtrs( const vector<Mat>& _hist, const Mat &_normSum ); void updatePtrs( const vector<Mat>& _hist, const Mat &_normSum );
bool read( const FileNode& node ); bool read( const FileNode& node );
enum { CELL_NUM = 4, BIN_NUM = 9 }; enum { CELL_NUM = 4, BIN_NUM = 9 };
Rect rect[CELL_NUM]; Rect rect[CELL_NUM];
int featComponent; //component index from 0 to 35 int featComponent; //component index from 0 to 35
const float* pF[4]; //for feature calculation const float* pF[4]; //for feature calculation
const float* pN[4]; //for normalization calculation const float* pN[4]; //for normalization calculation
}; };
HOGEvaluator(); HOGEvaluator();
virtual ~HOGEvaluator(); virtual ~HOGEvaluator();
virtual bool read( const FileNode& node ); virtual bool read( const FileNode& node );
virtual Ptr<FeatureEvaluator> clone() const; virtual Ptr<FeatureEvaluator> clone() const;
virtual int getFeatureType() const { return FeatureEvaluator::HOG; } virtual int getFeatureType() const { return FeatureEvaluator::HOG; }
virtual bool setImage( const Mat& image, Size winSize ); virtual bool setImage( const Mat& image, Size winSize );
virtual bool setWindow( Point pt ); virtual bool setWindow( Point pt );
double operator()(int featureIdx) const double operator()(int featureIdx) const
{ {
return featuresPtr[featureIdx].calc(offset); return featuresPtr[featureIdx].calc(offset);
} }
virtual double calcOrd( int featureIdx ) const virtual double calcOrd( int featureIdx ) const
{ {
return (*this)(featureIdx); return (*this)(featureIdx);
} }
private: private:
virtual void integralHistogram( const Mat& srcImage, vector<Mat> &histogram, Mat &norm, int nbins ) const; virtual void integralHistogram( const Mat& srcImage, vector<Mat> &histogram, Mat &norm, int nbins ) const;
Size origWinSize; Size origWinSize;
Ptr<vector<Feature>> features; Ptr<vector<Feature> > features;
Feature* featuresPtr; Feature* featuresPtr;
vector<Mat> hist; vector<Mat> hist;
Mat normSum; Mat normSum;
int offset; int offset;
}; };
inline HOGEvaluator::Feature :: Feature() inline HOGEvaluator::Feature :: Feature()
{ {
rect[0] = rect[1] = rect[2] = rect[3] = Rect(); rect[0] = rect[1] = rect[2] = rect[3] = Rect();
pF[0] = pF[1] = pF[2] = pF[3] = 0; pF[0] = pF[1] = pF[2] = pF[3] = 0;
pN[0] = pN[1] = pN[2] = pN[3] = 0; pN[0] = pN[1] = pN[2] = pN[3] = 0;
featComponent = 0; featComponent = 0;
} }
inline float HOGEvaluator::Feature :: calc( int offset ) const inline float HOGEvaluator::Feature :: calc( int offset ) const
{ {
float res = CALC_SUM(pF, offset); float res = CALC_SUM(pF, offset);
float normFactor = CALC_SUM(pN, offset); float normFactor = CALC_SUM(pN, offset);
res = (res > 0.001f) ? (res / ( normFactor + 0.001f) ) : 0.f; res = (res > 0.001f) ? (res / ( normFactor + 0.001f) ) : 0.f;
return res; return res;
} }
inline void HOGEvaluator::Feature :: updatePtrs( const vector<Mat> &_hist, const Mat &_normSum ) inline void HOGEvaluator::Feature :: updatePtrs( const vector<Mat> &_hist, const Mat &_normSum )
{ {
int binIdx = featComponent % BIN_NUM; int binIdx = featComponent % BIN_NUM;
int cellIdx = featComponent / BIN_NUM; int cellIdx = featComponent / BIN_NUM;
Rect normRect = Rect( rect[0].x, rect[0].y, 2*rect[0].width, 2*rect[0].height ); Rect normRect = Rect( rect[0].x, rect[0].y, 2*rect[0].width, 2*rect[0].height );
const float* featBuf = (const float*)_hist[binIdx].data; const float* featBuf = (const float*)_hist[binIdx].data;
size_t featStep = _hist[0].step / sizeof(featBuf[0]); size_t featStep = _hist[0].step / sizeof(featBuf[0]);
const float* normBuf = (const float*)_normSum.data; const float* normBuf = (const float*)_normSum.data;
size_t normStep = _normSum.step / sizeof(normBuf[0]); size_t normStep = _normSum.step / sizeof(normBuf[0]);
CV_SUM_PTRS( pF[0], pF[1], pF[2], pF[3], featBuf, rect[cellIdx], featStep ); CV_SUM_PTRS( pF[0], pF[1], pF[2], pF[3], featBuf, rect[cellIdx], featStep );
CV_SUM_PTRS( pN[0], pN[1], pN[2], pN[3], normBuf, normRect, normStep ); CV_SUM_PTRS( pN[0], pN[1], pN[2], pN[3], normBuf, normRect, normStep );
} }