|
|
|
@ -861,9 +861,10 @@ bool CascadeClassifier::setImage( Ptr<FeatureEvaluator>& featureEvaluator, const |
|
|
|
|
|
|
|
|
|
struct CascadeClassifierInvoker |
|
|
|
|
{ |
|
|
|
|
CascadeClassifierInvoker( CascadeClassifier& _cc, Size _sz1, int _stripSize, int _yStep, double _factor,
|
|
|
|
|
CascadeClassifierInvoker( const Mat& _image, CascadeClassifier& _cc, Size _sz1, int _stripSize, int _yStep, double _factor,
|
|
|
|
|
ConcurrentRectVector& _vec, vector<int>& _levels, vector<double>& _weights, bool outputLevels = false ) |
|
|
|
|
{ |
|
|
|
|
image=_image; |
|
|
|
|
classifier = &_cc; |
|
|
|
|
processingRectSize = _sz1; |
|
|
|
|
stripSize = _stripSize; |
|
|
|
@ -877,6 +878,10 @@ struct CascadeClassifierInvoker |
|
|
|
|
void operator()(const BlockedRange& range) const |
|
|
|
|
{ |
|
|
|
|
Ptr<FeatureEvaluator> evaluator = classifier->featureEvaluator->clone(); |
|
|
|
|
|
|
|
|
|
#ifdef HAVE_TEGRA_OPTIMIZATION |
|
|
|
|
Mat currentMask=tegra::getCascadeClassifierMask(image, classifier->data.origWinSize); |
|
|
|
|
#endif |
|
|
|
|
Size winSize(cvRound(classifier->data.origWinSize.width * scalingFactor), cvRound(classifier->data.origWinSize.height * scalingFactor)); |
|
|
|
|
|
|
|
|
|
int y1 = range.begin() * stripSize; |
|
|
|
@ -885,6 +890,12 @@ struct CascadeClassifierInvoker |
|
|
|
|
{ |
|
|
|
|
for( int x = 0; x < processingRectSize.width; x += yStep ) |
|
|
|
|
{ |
|
|
|
|
#ifdef HAVE_TEGRA_OPTIMIZATION |
|
|
|
|
if ( (!currentMask.empty()) && (currentMask.at<uchar>(Point(x,y))==0)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
double gypWeight; |
|
|
|
|
int result = classifier->runAt(evaluator, Point(x, y), gypWeight); |
|
|
|
|
if( rejectLevels ) |
|
|
|
@ -907,6 +918,7 @@ struct CascadeClassifierInvoker |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Mat image; |
|
|
|
|
CascadeClassifier* classifier; |
|
|
|
|
ConcurrentRectVector* rectangles; |
|
|
|
|
Size processingRectSize; |
|
|
|
@ -930,14 +942,14 @@ bool CascadeClassifier::detectSingleScale( const Mat& image, int stripCount, Siz |
|
|
|
|
vector<double> levelWeights; |
|
|
|
|
if( outputRejectLevels ) |
|
|
|
|
{ |
|
|
|
|
parallel_for(BlockedRange(0, stripCount), CascadeClassifierInvoker( *this, processingRectSize, stripSize, yStep, factor, |
|
|
|
|
parallel_for(BlockedRange(0, stripCount), CascadeClassifierInvoker( image, *this, processingRectSize, stripSize, yStep, factor, |
|
|
|
|
concurrentCandidates, rejectLevels, levelWeights, true)); |
|
|
|
|
levels.insert( levels.end(), rejectLevels.begin(), rejectLevels.end() ); |
|
|
|
|
weights.insert( weights.end(), levelWeights.begin(), levelWeights.end() ); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
parallel_for(BlockedRange(0, stripCount), CascadeClassifierInvoker( *this, processingRectSize, stripSize, yStep, factor, |
|
|
|
|
parallel_for(BlockedRange(0, stripCount), CascadeClassifierInvoker( image, *this, processingRectSize, stripSize, yStep, factor, |
|
|
|
|
concurrentCandidates, rejectLevels, levelWeights, false)); |
|
|
|
|
} |
|
|
|
|
candidates.insert( candidates.end(), concurrentCandidates.begin(), concurrentCandidates.end() ); |
|
|
|
|