fixed bug reported by Irina K. Also tried to fix LBP detector regression in quality (probably it did not help but still ...)

pull/2324/head
Vadim Pisarevsky 11 years ago
parent 511e79aef7
commit a18bc9651d
  1. 19
      modules/objdetect/src/cascadedetect.cpp
  2. 4
      modules/objdetect/src/cascadedetect.hpp

@ -88,6 +88,9 @@ void groupRectangles(std::vector<Rect>& rectList, int groupThreshold, double eps
rrects[cls].height += rectList[i].height; rrects[cls].height += rectList[i].height;
rweights[cls]++; rweights[cls]++;
} }
bool useDefaultWeights = false;
if ( levelWeights && weights && !weights->empty() && !levelWeights->empty() ) if ( levelWeights && weights && !weights->empty() && !levelWeights->empty() )
{ {
for( i = 0; i < nlabels; i++ ) for( i = 0; i < nlabels; i++ )
@ -102,6 +105,8 @@ void groupRectangles(std::vector<Rect>& rectList, int groupThreshold, double eps
rejectWeights[cls] = (*levelWeights)[i]; rejectWeights[cls] = (*levelWeights)[i];
} }
} }
else
useDefaultWeights = true;
for( i = 0; i < nclasses; i++ ) for( i = 0; i < nclasses; i++ )
{ {
@ -154,7 +159,7 @@ void groupRectangles(std::vector<Rect>& rectList, int groupThreshold, double eps
{ {
rectList.push_back(r1); rectList.push_back(r1);
if( weights ) if( weights )
weights->push_back(l1); weights->push_back(useDefaultWeights ? n1 : l1);
if( levelWeights ) if( levelWeights )
levelWeights->push_back(w1); levelWeights->push_back(w1);
} }
@ -575,16 +580,19 @@ bool HaarEvaluator::read(const FileNode& node, Size _origWinSize)
nchannels = hasTiltedFeatures ? 3 : 2; nchannels = hasTiltedFeatures ? 3 : 2;
normrect = Rect(1, 1, origWinSize.width - 2, origWinSize.height - 2); normrect = Rect(1, 1, origWinSize.width - 2, origWinSize.height - 2);
localSize = lbufSize = Size(0, 0);
if (ocl::haveOpenCL()) if (ocl::haveOpenCL())
{ {
String vname = ocl::Device::getDefault().vendor(); String vname = ocl::Device::getDefault().vendor();
if (vname == "Advanced Micro Devices, Inc." || if (vname == "Advanced Micro Devices, Inc." ||
vname == "AMD") vname == "AMD")
{
localSize = Size(8, 8); localSize = Size(8, 8);
lbufSize = Size(origWinSize.width + localSize.width, lbufSize = Size(origWinSize.width + localSize.width,
origWinSize.height + localSize.height); origWinSize.height + localSize.height);
if (lbufSize.area() > 1024) if (lbufSize.area() > 1024)
lbufSize = Size(0, 0); lbufSize = Size(0, 0);
}
} }
return true; return true;
@ -757,6 +765,7 @@ bool LBPEvaluator::read( const FileNode& node, Size _origWinSize )
return false; return false;
} }
nchannels = 1; nchannels = 1;
localSize = lbufSize = Size(0, 0);
if (ocl::haveOpenCL()) if (ocl::haveOpenCL())
{ {
const ocl::Device& device = ocl::Device::getDefault(); const ocl::Device& device = ocl::Device::getDefault();

@ -608,7 +608,7 @@ inline int predictCategoricalStump( CascadeClassifierImpl& cascade,
const CascadeClassifierImpl::Data::Stump* cascadeStumps = &cascade.data.stumps[0]; const CascadeClassifierImpl::Data::Stump* cascadeStumps = &cascade.data.stumps[0];
const CascadeClassifierImpl::Data::Stage* cascadeStages = &cascade.data.stages[0]; const CascadeClassifierImpl::Data::Stage* cascadeStages = &cascade.data.stages[0];
float tmp = 0; double tmp = 0;
for( int si = 0; si < nstages; si++ ) for( int si = 0; si < nstages; si++ )
{ {
const CascadeClassifierImpl::Data::Stage& stage = cascadeStages[si]; const CascadeClassifierImpl::Data::Stage& stage = cascadeStages[si];
@ -625,7 +625,7 @@ inline int predictCategoricalStump( CascadeClassifierImpl& cascade,
if( tmp < stage.threshold ) if( tmp < stage.threshold )
{ {
sum = (double)tmp; sum = tmp;
return -si; return -si;
} }

Loading…
Cancel
Save