From: Vadim Pisarevsky Date: Wed, 12 Feb 2014 13:42:09 +0000 (+0400) Subject: fixed bug reported by Irina K. Also tried to fix LBP detector regression in quality... X-Git-Tag: submit/tizen_ivi/20141117.190038~2^2~624^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a18bc9651d82b1dc2e2f17ecb32c8a798372dea0;p=profile%2Fivi%2Fopencv.git fixed bug reported by Irina K. Also tried to fix LBP detector regression in quality (probably it did not help but still ...) --- diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp index ef9d21e..c62dbfb 100644 --- a/modules/objdetect/src/cascadedetect.cpp +++ b/modules/objdetect/src/cascadedetect.cpp @@ -88,6 +88,9 @@ void groupRectangles(std::vector& rectList, int groupThreshold, double eps rrects[cls].height += rectList[i].height; rweights[cls]++; } + + bool useDefaultWeights = false; + if ( levelWeights && weights && !weights->empty() && !levelWeights->empty() ) { for( i = 0; i < nlabels; i++ ) @@ -102,6 +105,8 @@ void groupRectangles(std::vector& rectList, int groupThreshold, double eps rejectWeights[cls] = (*levelWeights)[i]; } } + else + useDefaultWeights = true; for( i = 0; i < nclasses; i++ ) { @@ -154,7 +159,7 @@ void groupRectangles(std::vector& rectList, int groupThreshold, double eps { rectList.push_back(r1); if( weights ) - weights->push_back(l1); + weights->push_back(useDefaultWeights ? n1 : l1); if( levelWeights ) levelWeights->push_back(w1); } @@ -575,16 +580,19 @@ bool HaarEvaluator::read(const FileNode& node, Size _origWinSize) nchannels = hasTiltedFeatures ? 3 : 2; normrect = Rect(1, 1, origWinSize.width - 2, origWinSize.height - 2); + localSize = lbufSize = Size(0, 0); if (ocl::haveOpenCL()) { String vname = ocl::Device::getDefault().vendor(); if (vname == "Advanced Micro Devices, Inc." || vname == "AMD") + { localSize = Size(8, 8); - lbufSize = Size(origWinSize.width + localSize.width, - origWinSize.height + localSize.height); - if (lbufSize.area() > 1024) - lbufSize = Size(0, 0); + lbufSize = Size(origWinSize.width + localSize.width, + origWinSize.height + localSize.height); + if (lbufSize.area() > 1024) + lbufSize = Size(0, 0); + } } return true; @@ -757,6 +765,7 @@ bool LBPEvaluator::read( const FileNode& node, Size _origWinSize ) return false; } nchannels = 1; + localSize = lbufSize = Size(0, 0); if (ocl::haveOpenCL()) { const ocl::Device& device = ocl::Device::getDefault(); diff --git a/modules/objdetect/src/cascadedetect.hpp b/modules/objdetect/src/cascadedetect.hpp index 166d05b..17eeccd 100644 --- a/modules/objdetect/src/cascadedetect.hpp +++ b/modules/objdetect/src/cascadedetect.hpp @@ -608,7 +608,7 @@ inline int predictCategoricalStump( CascadeClassifierImpl& cascade, const CascadeClassifierImpl::Data::Stump* cascadeStumps = &cascade.data.stumps[0]; const CascadeClassifierImpl::Data::Stage* cascadeStages = &cascade.data.stages[0]; - float tmp = 0; + double tmp = 0; for( int si = 0; si < nstages; si++ ) { const CascadeClassifierImpl::Data::Stage& stage = cascadeStages[si]; @@ -625,7 +625,7 @@ inline int predictCategoricalStump( CascadeClassifierImpl& cascade, if( tmp < stage.threshold ) { - sum = (double)tmp; + sum = tmp; return -si; }