calculate innTilted only for Haar::ALL mode

major time consuming part for training app is in function fillPassedSamples for negatives, 
this change make SetImage quicker, in a test of my own data, the total time for SetImage decrease from 9177666 to 5839263,
only help for Haar feature and non Haar::ALL mode which is the most commonly case
This commit is contained in:
Teng Cao 2015-12-07 18:50:54 +08:00
parent 7172c16435
commit d68c392b42

View File

@ -100,9 +100,13 @@ void CvHaarEvaluator::setImage(const Mat& img, uchar clsLabel, int idx)
CV_DbgAssert( !sum.empty() && !tilted.empty() && !normfactor.empty() );
CvFeatureEvaluator::setImage( img, clsLabel, idx);
Mat innSum(winSize.height + 1, winSize.width + 1, sum.type(), sum.ptr<int>((int)idx));
Mat innTilted(winSize.height + 1, winSize.width + 1, tilted.type(), tilted.ptr<int>((int)idx));
Mat innSqSum;
integral(img, innSum, innSqSum, innTilted);
if (((const CvHaarFeatureParams*)featureParams)->mode == CvHaarFeatureParams::ALL) {
Mat innTilted(winSize.height + 1, winSize.width + 1, tilted.type(), tilted.ptr<int>((int)idx));
integral(img, innSum, innSqSum, innTilted);
}
else
integral(img, innSum, innSqSum);
normfactor.ptr<float>(0)[idx] = calcNormFactor( innSum, innSqSum );
}