From 25cadb1abd08a9b50bdba64b03f29ad2e6f1d287 Mon Sep 17 00:00:00 2001 From: Anatoly Baksheev Date: Wed, 21 Sep 2011 18:25:22 +0000 Subject: [PATCH] fixed compilation under ubuntu --- modules/objdetect/src/cascadedetect.hpp | 156 ++++++++++++------------ 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/modules/objdetect/src/cascadedetect.hpp b/modules/objdetect/src/cascadedetect.hpp index 160798dc64..c78b9a2782 100644 --- a/modules/objdetect/src/cascadedetect.hpp +++ b/modules/objdetect/src/cascadedetect.hpp @@ -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 ); } -//---------------------------------------------- HOGEvaluator ------------------------------------------- - -class HOGEvaluator : public FeatureEvaluator -{ -public: - struct Feature - { - Feature(); - float calc( int offset ) const; - void updatePtrs( const vector& _hist, const Mat &_normSum ); - bool read( const FileNode& node ); - - enum { CELL_NUM = 4, BIN_NUM = 9 }; - - Rect rect[CELL_NUM]; - int featComponent; //component index from 0 to 35 - const float* pF[4]; //for feature calculation - const float* pN[4]; //for normalization calculation - }; - HOGEvaluator(); - virtual ~HOGEvaluator(); - virtual bool read( const FileNode& node ); - virtual Ptr clone() const; - virtual int getFeatureType() const { return FeatureEvaluator::HOG; } - virtual bool setImage( const Mat& image, Size winSize ); - virtual bool setWindow( Point pt ); - double operator()(int featureIdx) const - { - return featuresPtr[featureIdx].calc(offset); - } - virtual double calcOrd( int featureIdx ) const - { - return (*this)(featureIdx); - } - -private: - virtual void integralHistogram( const Mat& srcImage, vector &histogram, Mat &norm, int nbins ) const; - - Size origWinSize; - Ptr> features; - Feature* featuresPtr; - vector hist; - Mat normSum; - int offset; -}; - -inline HOGEvaluator::Feature :: Feature() -{ - rect[0] = rect[1] = rect[2] = rect[3] = Rect(); - pF[0] = pF[1] = pF[2] = pF[3] = 0; - pN[0] = pN[1] = pN[2] = pN[3] = 0; - featComponent = 0; -} - -inline float HOGEvaluator::Feature :: calc( int offset ) const -{ - float res = CALC_SUM(pF, offset); - float normFactor = CALC_SUM(pN, offset); - res = (res > 0.001f) ? (res / ( normFactor + 0.001f) ) : 0.f; - return res; -} - -inline void HOGEvaluator::Feature :: updatePtrs( const vector &_hist, const Mat &_normSum ) -{ - int binIdx = 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 ); - - const float* featBuf = (const float*)_hist[binIdx].data; - size_t featStep = _hist[0].step / sizeof(featBuf[0]); - - const float* normBuf = (const float*)_normSum.data; - 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( pN[0], pN[1], pN[2], pN[3], normBuf, normRect, normStep ); -} - +//---------------------------------------------- HOGEvaluator ------------------------------------------- + +class HOGEvaluator : public FeatureEvaluator +{ +public: + struct Feature + { + Feature(); + float calc( int offset ) const; + void updatePtrs( const vector& _hist, const Mat &_normSum ); + bool read( const FileNode& node ); + + enum { CELL_NUM = 4, BIN_NUM = 9 }; + + Rect rect[CELL_NUM]; + int featComponent; //component index from 0 to 35 + const float* pF[4]; //for feature calculation + const float* pN[4]; //for normalization calculation + }; + HOGEvaluator(); + virtual ~HOGEvaluator(); + virtual bool read( const FileNode& node ); + virtual Ptr clone() const; + virtual int getFeatureType() const { return FeatureEvaluator::HOG; } + virtual bool setImage( const Mat& image, Size winSize ); + virtual bool setWindow( Point pt ); + double operator()(int featureIdx) const + { + return featuresPtr[featureIdx].calc(offset); + } + virtual double calcOrd( int featureIdx ) const + { + return (*this)(featureIdx); + } + +private: + virtual void integralHistogram( const Mat& srcImage, vector &histogram, Mat &norm, int nbins ) const; + + Size origWinSize; + Ptr > features; + Feature* featuresPtr; + vector hist; + Mat normSum; + int offset; +}; + +inline HOGEvaluator::Feature :: Feature() +{ + rect[0] = rect[1] = rect[2] = rect[3] = Rect(); + pF[0] = pF[1] = pF[2] = pF[3] = 0; + pN[0] = pN[1] = pN[2] = pN[3] = 0; + featComponent = 0; +} + +inline float HOGEvaluator::Feature :: calc( int offset ) const +{ + float res = CALC_SUM(pF, offset); + float normFactor = CALC_SUM(pN, offset); + res = (res > 0.001f) ? (res / ( normFactor + 0.001f) ) : 0.f; + return res; +} + +inline void HOGEvaluator::Feature :: updatePtrs( const vector &_hist, const Mat &_normSum ) +{ + int binIdx = 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 ); + + const float* featBuf = (const float*)_hist[binIdx].data; + size_t featStep = _hist[0].step / sizeof(featBuf[0]); + + const float* normBuf = (const float*)_normSum.data; + 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( pN[0], pN[1], pN[2], pN[3], normBuf, normRect, normStep ); +} +