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 float HaarEvaluator::Feature :: calc( int offset ) const { float ret = rect[0].weight * CALC_SUM(p[0], offset) + rect[1].weight * CALC_SUM(p[1], offset); if( rect[2].weight != 0.0f ) ret += rect[2].weight * CALC_SUM(p[2], offset); return ret; }
bool HaarEvaluator::setWindow( Point pt ) { if( pt.x < 0 || pt.y < 0 || pt.x + origWinSize.width >= sum.cols || pt.y + origWinSize.height >= sum.rows ) return false; size_t pOffset = pt.y * (sum.step/sizeof(int)) + pt.x; size_t pqOffset = pt.y * (sqsum.step/sizeof(double)) + pt.x; int valsum = CALC_SUM(p, pOffset); double valsqsum = CALC_SUM(pq, pqOffset); double nf = (double)normrect.area() * valsqsum - (double)valsum * valsum; if( nf > 0. ) nf = std::sqrt(nf); else nf = 1.; varianceNormFactor = 1./nf; offset = (int)pOffset; return true; }