Commit f41f633d authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

fixed various warnings from the “doc” and other builders

parent a1784b73
...@@ -426,7 +426,7 @@ public: ...@@ -426,7 +426,7 @@ public:
int i = set(0, a0); i = set(i, a1); i = set(i, a2); i = set(i, a3); i = set(i, a4); i = set(i, a5); int i = set(0, a0); i = set(i, a1); i = set(i, a2); i = set(i, a3); i = set(i, a4); i = set(i, a5);
i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); set(i, a11); return *this; i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); set(i, a11); return *this;
} }
template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3,
typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7,
typename _Tp8, typename _Tp9, typename _Tp10, typename _Tp11, typename _Tp12> typename _Tp8, typename _Tp9, typename _Tp10, typename _Tp11, typename _Tp12>
...@@ -439,7 +439,7 @@ public: ...@@ -439,7 +439,7 @@ public:
i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); i = set(i, a11); i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); i = set(i, a11);
set(i, a12); return *this; set(i, a12); return *this;
} }
template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3,
typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7,
typename _Tp8, typename _Tp9, typename _Tp10, typename _Tp11, typename _Tp12, typename _Tp8, typename _Tp9, typename _Tp10, typename _Tp11, typename _Tp12,
...@@ -453,7 +453,7 @@ public: ...@@ -453,7 +453,7 @@ public:
i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); i = set(i, a11); i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); i = set(i, a11);
i = set(i, a12); set(i, a13); return *this; i = set(i, a12); set(i, a13); return *this;
} }
template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3,
typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7,
typename _Tp8, typename _Tp9, typename _Tp10, typename _Tp11, typename _Tp12, typename _Tp8, typename _Tp9, typename _Tp10, typename _Tp11, typename _Tp12,
...@@ -467,7 +467,7 @@ public: ...@@ -467,7 +467,7 @@ public:
i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); i = set(i, a11); i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); i = set(i, a11);
i = set(i, a12); i = set(i, a13); set(i, a14); return *this; i = set(i, a12); i = set(i, a13); set(i, a14); return *this;
} }
template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3,
typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7,
typename _Tp8, typename _Tp9, typename _Tp10, typename _Tp11, typename _Tp12, typename _Tp8, typename _Tp9, typename _Tp10, typename _Tp11, typename _Tp12,
......
...@@ -1075,7 +1075,7 @@ CV_EXPORTS_W void boxFilter( InputArray src, OutputArray dst, int ddepth, ...@@ -1075,7 +1075,7 @@ CV_EXPORTS_W void boxFilter( InputArray src, OutputArray dst, int ddepth,
Size ksize, Point anchor = Point(-1,-1), Size ksize, Point anchor = Point(-1,-1),
bool normalize = true, bool normalize = true,
int borderType = BORDER_DEFAULT ); int borderType = BORDER_DEFAULT );
CV_EXPORTS_W void sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth, CV_EXPORTS_W void sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth,
Size ksize, Point anchor = Point(-1, -1), Size ksize, Point anchor = Point(-1, -1),
bool normalize = true, bool normalize = true,
......
...@@ -910,13 +910,13 @@ template<typename T, typename ST> struct SqrRowSum : public BaseRowFilter ...@@ -910,13 +910,13 @@ template<typename T, typename ST> struct SqrRowSum : public BaseRowFilter
ksize = _ksize; ksize = _ksize;
anchor = _anchor; anchor = _anchor;
} }
void operator()(const uchar* src, uchar* dst, int width, int cn) void operator()(const uchar* src, uchar* dst, int width, int cn)
{ {
const T* S = (const T*)src; const T* S = (const T*)src;
ST* D = (ST*)dst; ST* D = (ST*)dst;
int i = 0, k, ksz_cn = ksize*cn; int i = 0, k, ksz_cn = ksize*cn;
width = (width - 1)*cn; width = (width - 1)*cn;
for( k = 0; k < cn; k++, S++, D++ ) for( k = 0; k < cn; k++, S++, D++ )
{ {
...@@ -941,10 +941,10 @@ static Ptr<BaseRowFilter> getSqrRowSumFilter(int srcType, int sumType, int ksize ...@@ -941,10 +941,10 @@ static Ptr<BaseRowFilter> getSqrRowSumFilter(int srcType, int sumType, int ksize
{ {
int sdepth = CV_MAT_DEPTH(srcType), ddepth = CV_MAT_DEPTH(sumType); int sdepth = CV_MAT_DEPTH(srcType), ddepth = CV_MAT_DEPTH(sumType);
CV_Assert( CV_MAT_CN(sumType) == CV_MAT_CN(srcType) ); CV_Assert( CV_MAT_CN(sumType) == CV_MAT_CN(srcType) );
if( anchor < 0 ) if( anchor < 0 )
anchor = ksize/2; anchor = ksize/2;
if( sdepth == CV_8U && ddepth == CV_32S ) if( sdepth == CV_8U && ddepth == CV_32S )
return makePtr<SqrRowSum<uchar, int> >(ksize, anchor); return makePtr<SqrRowSum<uchar, int> >(ksize, anchor);
if( sdepth == CV_8U && ddepth == CV_64F ) if( sdepth == CV_8U && ddepth == CV_64F )
...@@ -957,11 +957,11 @@ static Ptr<BaseRowFilter> getSqrRowSumFilter(int srcType, int sumType, int ksize ...@@ -957,11 +957,11 @@ static Ptr<BaseRowFilter> getSqrRowSumFilter(int srcType, int sumType, int ksize
return makePtr<SqrRowSum<float, double> >(ksize, anchor); return makePtr<SqrRowSum<float, double> >(ksize, anchor);
if( sdepth == CV_64F && ddepth == CV_64F ) if( sdepth == CV_64F && ddepth == CV_64F )
return makePtr<SqrRowSum<double, double> >(ksize, anchor); return makePtr<SqrRowSum<double, double> >(ksize, anchor);
CV_Error_( CV_StsNotImplemented, CV_Error_( CV_StsNotImplemented,
("Unsupported combination of source format (=%d), and buffer format (=%d)", ("Unsupported combination of source format (=%d), and buffer format (=%d)",
srcType, sumType)); srcType, sumType));
return Ptr<BaseRowFilter>(); return Ptr<BaseRowFilter>();
} }
...@@ -984,19 +984,19 @@ void cv::sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth, ...@@ -984,19 +984,19 @@ void cv::sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth,
if( src.cols == 1 ) if( src.cols == 1 )
ksize.width = 1; ksize.width = 1;
} }
int sumType = CV_64F; int sumType = CV_64F;
if( sdepth == CV_8U ) if( sdepth == CV_8U )
sumType = CV_32S; sumType = CV_32S;
sumType = CV_MAKETYPE( sumType, cn ); sumType = CV_MAKETYPE( sumType, cn );
int srcType = CV_MAKETYPE(sdepth, cn); int srcType = CV_MAKETYPE(sdepth, cn);
int dstType = CV_MAKETYPE(ddepth, cn); int dstType = CV_MAKETYPE(ddepth, cn);
Ptr<BaseRowFilter> rowFilter = getSqrRowSumFilter(srcType, sumType, ksize.width, anchor.x ); Ptr<BaseRowFilter> rowFilter = getSqrRowSumFilter(srcType, sumType, ksize.width, anchor.x );
Ptr<BaseColumnFilter> columnFilter = getColumnSumFilter(sumType, Ptr<BaseColumnFilter> columnFilter = getColumnSumFilter(sumType,
dstType, ksize.height, anchor.y, dstType, ksize.height, anchor.y,
normalize ? 1./(ksize.width*ksize.height) : 1); normalize ? 1./(ksize.width*ksize.height) : 1);
Ptr<FilterEngine> f = makePtr<FilterEngine>(Ptr<BaseFilter>(), rowFilter, columnFilter, Ptr<FilterEngine> f = makePtr<FilterEngine>(Ptr<BaseFilter>(), rowFilter, columnFilter,
srcType, dstType, sumType, borderType ); srcType, dstType, sumType, borderType );
f->apply( src, dst ); f->apply( src, dst );
......
...@@ -86,11 +86,13 @@ FeatureEvaluator::setImage ...@@ -86,11 +86,13 @@ FeatureEvaluator::setImage
------------------------------ ------------------------------
Assigns an image to feature evaluator. Assigns an image to feature evaluator.
.. ocv:function:: bool FeatureEvaluator::setImage(const Mat& img, Size origWinSize) .. ocv:function:: bool FeatureEvaluator::setImage(InputArray img, Size origWinSize, Size sumSize)
:param img: Matrix of the type ``CV_8UC1`` containing an image where the features are computed. :param img: Matrix of the type ``CV_8UC1`` containing an image where the features are computed.
:param origWinSize: Size of training images. :param origWinSize: Size of training images.
:param sumSize: The requested size of integral images (so if the integral image is smaller, it resides in the top-left corner of the larger image of requested size). Because the features are represented using offsets from the image origin, using the same sumSize for all scales helps to avoid constant readjustments of the features to different scales.
The method assigns an image, where the features will be computed, to the feature evaluator. The method assigns an image, where the features will be computed, to the feature evaluator.
......
...@@ -113,12 +113,12 @@ struct Logger ...@@ -113,12 +113,12 @@ struct Logger
namespace cv namespace cv
{ {
template<typename _Tp> void copyVectorToUMat(const std::vector<_Tp>& v, UMat& um) template<typename _Tp> void copyVectorToUMat(const std::vector<_Tp>& v, UMat& um)
{ {
if(v.empty()) if(v.empty())
um.release(); um.release();
Mat(1, (int)(v.size()*sizeof(v[0])), CV_8U, (void*)&v[0]).copyTo(um); Mat(1, (int)(v.size()*sizeof(v[0])), CV_8U, (void*)&v[0]).copyTo(um);
} }
void groupRectangles(std::vector<Rect>& rectList, int groupThreshold, double eps, std::vector<int>* weights, std::vector<double>* levelWeights) void groupRectangles(std::vector<Rect>& rectList, int groupThreshold, double eps, std::vector<int>* weights, std::vector<double>* levelWeights)
...@@ -528,24 +528,24 @@ bool HaarEvaluator::setImage( InputArray _image, Size _origWinSize, Size _sumSiz ...@@ -528,24 +528,24 @@ bool HaarEvaluator::setImage( InputArray _image, Size _origWinSize, Size _sumSiz
{ {
Size imgsz = _image.size(); Size imgsz = _image.size();
int cols = imgsz.width, rows = imgsz.height; int cols = imgsz.width, rows = imgsz.height;
if (imgsz.width < origWinSize.width || imgsz.height < origWinSize.height) if (imgsz.width < origWinSize.width || imgsz.height < origWinSize.height)
return false; return false;
origWinSize = _origWinSize; origWinSize = _origWinSize;
normrect = Rect(1, 1, origWinSize.width-2, origWinSize.height-2); normrect = Rect(1, 1, origWinSize.width-2, origWinSize.height-2);
int rn = _sumSize.height, cn = _sumSize.width, rn_scale = hasTiltedFeatures ? 2 : 1; int rn = _sumSize.height, cn = _sumSize.width, rn_scale = hasTiltedFeatures ? 2 : 1;
int sumStep, tofs = 0; int sumStep, tofs = 0;
CV_Assert(rn >= rows+1 && cn >= cols+1); CV_Assert(rn >= rows+1 && cn >= cols+1);
if( _image.isUMat() ) if( _image.isUMat() )
{ {
usum0.create(rn*rn_scale, cn, CV_32S); usum0.create(rn*rn_scale, cn, CV_32S);
usqsum0.create(rn, cn, CV_32S); usqsum0.create(rn, cn, CV_32S);
usum = UMat(usum0, Rect(0, 0, cols+1, rows+1)); usum = UMat(usum0, Rect(0, 0, cols+1, rows+1));
usqsum = UMat(usqsum0, Rect(0, 0, cols, rows)); usqsum = UMat(usqsum0, Rect(0, 0, cols, rows));
if( hasTiltedFeatures ) if( hasTiltedFeatures )
{ {
UMat utilted(usum0, Rect(0, _sumSize.height, cols+1, rows+1)); UMat utilted(usum0, Rect(0, _sumSize.height, cols+1, rows+1));
...@@ -556,7 +556,7 @@ bool HaarEvaluator::setImage( InputArray _image, Size _origWinSize, Size _sumSiz ...@@ -556,7 +556,7 @@ bool HaarEvaluator::setImage( InputArray _image, Size _origWinSize, Size _sumSiz
{ {
integral(_image, usum, noArray(), noArray(), CV_32S); integral(_image, usum, noArray(), noArray(), CV_32S);
} }
sqrBoxFilter(_image, usqsum, CV_32S, sqrBoxFilter(_image, usqsum, CV_32S,
Size(normrect.width, normrect.height), Size(normrect.width, normrect.height),
Point(0, 0), false); Point(0, 0), false);
...@@ -572,7 +572,7 @@ bool HaarEvaluator::setImage( InputArray _image, Size _origWinSize, Size _sumSiz ...@@ -572,7 +572,7 @@ bool HaarEvaluator::setImage( InputArray _image, Size _origWinSize, Size _sumSiz
sqsum0.create(rn, cn, CV_32S); sqsum0.create(rn, cn, CV_32S);
sum = sum0(Rect(0, 0, cols+1, rows+1)); sum = sum0(Rect(0, 0, cols+1, rows+1));
sqsum = sqsum0(Rect(0, 0, cols, rows)); sqsum = sqsum0(Rect(0, 0, cols, rows));
if( hasTiltedFeatures ) if( hasTiltedFeatures )
{ {
Mat tilted = sum0(Rect(0, _sumSize.height, cols+1, rows+1)); Mat tilted = sum0(Rect(0, _sumSize.height, cols+1, rows+1));
...@@ -591,7 +591,7 @@ bool HaarEvaluator::setImage( InputArray _image, Size _origWinSize, Size _sumSiz ...@@ -591,7 +591,7 @@ bool HaarEvaluator::setImage( InputArray _image, Size _origWinSize, Size _sumSiz
size_t fi, nfeatures = features->size(); size_t fi, nfeatures = features->size();
const std::vector<Feature>& ff = *features; const std::vector<Feature>& ff = *features;
if( sumSize0 != _sumSize ) if( sumSize0 != _sumSize )
{ {
optfeatures->resize(nfeatures); optfeatures->resize(nfeatures);
...@@ -600,13 +600,13 @@ bool HaarEvaluator::setImage( InputArray _image, Size _origWinSize, Size _sumSiz ...@@ -600,13 +600,13 @@ bool HaarEvaluator::setImage( InputArray _image, Size _origWinSize, Size _sumSiz
optfeaturesPtr[fi].setOffsets( ff[fi], sumStep, tofs ); optfeaturesPtr[fi].setOffsets( ff[fi], sumStep, tofs );
} }
if( _image.isUMat() && (sumSize0 != _sumSize || ufbuf.empty()) ) if( _image.isUMat() && (sumSize0 != _sumSize || ufbuf.empty()) )
copyVectorToUMat(*optfeatures, ufbuf); copyVectorToUMat(*optfeatures, ufbuf);
sumSize0 = _sumSize; sumSize0 = _sumSize;
return true; return true;
} }
bool HaarEvaluator::setWindow( Point pt ) bool HaarEvaluator::setWindow( Point pt )
{ {
if( pt.x < 0 || pt.y < 0 || if( pt.x < 0 || pt.y < 0 ||
...@@ -628,12 +628,12 @@ bool HaarEvaluator::setWindow( Point pt ) ...@@ -628,12 +628,12 @@ bool HaarEvaluator::setWindow( Point pt )
return true; return true;
} }
Rect HaarEvaluator::getNormRect() const Rect HaarEvaluator::getNormRect() const
{ {
return normrect; return normrect;
} }
void HaarEvaluator::getUMats(std::vector<UMat>& bufs) void HaarEvaluator::getUMats(std::vector<UMat>& bufs)
{ {
bufs.clear(); bufs.clear();
...@@ -1100,14 +1100,14 @@ bool CascadeClassifierImpl::detectSingleScale( InputArray _image, Size processin ...@@ -1100,14 +1100,14 @@ bool CascadeClassifierImpl::detectSingleScale( InputArray _image, Size processin
std::vector<Rect> candidatesVector; std::vector<Rect> candidatesVector;
std::vector<int> rejectLevels; std::vector<int> rejectLevels;
std::vector<double> levelWeights; std::vector<double> levelWeights;
int stripCount, stripSize; int stripCount, stripSize;
const int PTS_PER_THREAD = 1000; const int PTS_PER_THREAD = 1000;
stripCount = ((processingRectSize.width/yStep)*(processingRectSize.height + yStep-1)/yStep + PTS_PER_THREAD/2)/PTS_PER_THREAD; stripCount = ((processingRectSize.width/yStep)*(processingRectSize.height + yStep-1)/yStep + PTS_PER_THREAD/2)/PTS_PER_THREAD;
stripCount = std::min(std::max(stripCount, 1), 100); stripCount = std::min(std::max(stripCount, 1), 100);
stripSize = (((processingRectSize.height + stripCount - 1)/stripCount + yStep-1)/yStep)*yStep; stripSize = (((processingRectSize.height + stripCount - 1)/stripCount + yStep-1)/yStep)*yStep;
if( outputRejectLevels ) if( outputRejectLevels )
{ {
parallel_for_(Range(0, stripCount), CascadeClassifierInvoker( *this, processingRectSize, stripSize, yStep, factor, parallel_for_(Range(0, stripCount), CascadeClassifierInvoker( *this, processingRectSize, stripSize, yStep, factor,
...@@ -1129,7 +1129,7 @@ bool CascadeClassifierImpl::detectSingleScale( InputArray _image, Size processin ...@@ -1129,7 +1129,7 @@ bool CascadeClassifierImpl::detectSingleScale( InputArray _image, Size processin
return true; return true;
} }
bool CascadeClassifierImpl::ocl_detectSingleScale( InputArray _image, Size processingRectSize, bool CascadeClassifierImpl::ocl_detectSingleScale( InputArray _image, Size processingRectSize,
int yStep, double factor, Size sumSize0 ) int yStep, double factor, Size sumSize0 )
{ {
...@@ -1137,9 +1137,9 @@ bool CascadeClassifierImpl::ocl_detectSingleScale( InputArray _image, Size proce ...@@ -1137,9 +1137,9 @@ bool CascadeClassifierImpl::ocl_detectSingleScale( InputArray _image, Size proce
Ptr<HaarEvaluator> haar = featureEvaluator.dynamicCast<HaarEvaluator>(); Ptr<HaarEvaluator> haar = featureEvaluator.dynamicCast<HaarEvaluator>();
if( haar.empty() ) if( haar.empty() )
return false; return false;
haar->setImage(_image, data.origWinSize, sumSize0); haar->setImage(_image, data.origWinSize, sumSize0);
if( cascadeKernel.empty() ) if( cascadeKernel.empty() )
{ {
cascadeKernel.create("runHaarClassifierStump", ocl::objdetect::cascadedetect_oclsrc, cascadeKernel.create("runHaarClassifierStump", ocl::objdetect::cascadedetect_oclsrc,
...@@ -1147,31 +1147,31 @@ bool CascadeClassifierImpl::ocl_detectSingleScale( InputArray _image, Size proce ...@@ -1147,31 +1147,31 @@ bool CascadeClassifierImpl::ocl_detectSingleScale( InputArray _image, Size proce
if( cascadeKernel.empty() ) if( cascadeKernel.empty() )
return false; return false;
} }
if( ustages.empty() ) if( ustages.empty() )
{ {
copyVectorToUMat(data.stages, ustages); copyVectorToUMat(data.stages, ustages);
copyVectorToUMat(data.stumps, ustumps); copyVectorToUMat(data.stumps, ustumps);
} }
std::vector<UMat> bufs; std::vector<UMat> bufs;
haar->getUMats(bufs); haar->getUMats(bufs);
CV_Assert(bufs.size() == 3); CV_Assert(bufs.size() == 3);
Rect normrect = haar->getNormRect(); Rect normrect = haar->getNormRect();
//processingRectSize = Size(yStep, yStep); //processingRectSize = Size(yStep, yStep);
size_t globalsize[] = { (processingRectSize.width/yStep + VECTOR_SIZE-1)/VECTOR_SIZE, processingRectSize.height/yStep }; size_t globalsize[] = { (processingRectSize.width/yStep + VECTOR_SIZE-1)/VECTOR_SIZE, processingRectSize.height/yStep };
cascadeKernel.args(ocl::KernelArg::ReadOnlyNoSize(bufs[0]), // sum cascadeKernel.args(ocl::KernelArg::ReadOnlyNoSize(bufs[0]), // sum
ocl::KernelArg::ReadOnlyNoSize(bufs[1]), // sqsum ocl::KernelArg::ReadOnlyNoSize(bufs[1]), // sqsum
ocl::KernelArg::PtrReadOnly(bufs[2]), // optfeatures ocl::KernelArg::PtrReadOnly(bufs[2]), // optfeatures
// cascade classifier // cascade classifier
(int)data.stages.size(), (int)data.stages.size(),
ocl::KernelArg::PtrReadOnly(ustages), ocl::KernelArg::PtrReadOnly(ustages),
ocl::KernelArg::PtrReadOnly(ustumps), ocl::KernelArg::PtrReadOnly(ustumps),
ocl::KernelArg::PtrWriteOnly(ufacepos), // positions ocl::KernelArg::PtrWriteOnly(ufacepos), // positions
processingRectSize, processingRectSize,
yStep, (float)factor, yStep, (float)factor,
...@@ -1219,7 +1219,7 @@ static void detectMultiScaleOldFormat( const Mat& image, Ptr<CvHaarClassifierCas ...@@ -1219,7 +1219,7 @@ static void detectMultiScaleOldFormat( const Mat& image, Ptr<CvHaarClassifierCas
std::transform(vecAvgComp.begin(), vecAvgComp.end(), objects.begin(), getRect()); std::transform(vecAvgComp.begin(), vecAvgComp.end(), objects.begin(), getRect());
} }
void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std::vector<Rect>& candidates, void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std::vector<Rect>& candidates,
std::vector<int>& rejectLevels, std::vector<double>& levelWeights, std::vector<int>& rejectLevels, std::vector<double>& levelWeights,
double scaleFactor, Size minObjectSize, Size maxObjectSize, double scaleFactor, Size minObjectSize, Size maxObjectSize,
...@@ -1227,16 +1227,16 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std:: ...@@ -1227,16 +1227,16 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std::
{ {
Size imgsz = _image.size(); Size imgsz = _image.size();
int imgtype = _image.type(); int imgtype = _image.type();
Mat grayImage, imageBuffer; Mat grayImage, imageBuffer;
candidates.clear(); candidates.clear();
rejectLevels.clear(); rejectLevels.clear();
levelWeights.clear(); levelWeights.clear();
if( maxObjectSize.height == 0 || maxObjectSize.width == 0 ) if( maxObjectSize.height == 0 || maxObjectSize.width == 0 )
maxObjectSize = imgsz; maxObjectSize = imgsz;
bool use_ocl = ocl::useOpenCL() && bool use_ocl = ocl::useOpenCL() &&
getFeatureType() == FeatureEvaluator::HAAR && getFeatureType() == FeatureEvaluator::HAAR &&
!isOldFormatCascade() && !isOldFormatCascade() &&
...@@ -1244,7 +1244,7 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std:: ...@@ -1244,7 +1244,7 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std::
maskGenerator.empty() && maskGenerator.empty() &&
!outputRejectLevels && !outputRejectLevels &&
tryOpenCL; tryOpenCL;
if( !use_ocl ) if( !use_ocl )
{ {
Mat image = _image.getMat(); Mat image = _image.getMat();
...@@ -1270,9 +1270,9 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std:: ...@@ -1270,9 +1270,9 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std::
uimage.copyTo(ugrayImage); uimage.copyTo(ugrayImage);
uimageBuffer.create(imgsz.height + 1, imgsz.width + 1, CV_8U); uimageBuffer.create(imgsz.height + 1, imgsz.width + 1, CV_8U);
} }
Size sumSize0((imgsz.width + SUM_ALIGN) & -SUM_ALIGN, imgsz.height+1); Size sumSize0((imgsz.width + SUM_ALIGN) & -SUM_ALIGN, imgsz.height+1);
if( use_ocl ) if( use_ocl )
{ {
ufacepos.create(1, MAX_FACES*4 + 1, CV_32S); ufacepos.create(1, MAX_FACES*4 + 1, CV_32S);
...@@ -1295,7 +1295,7 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std:: ...@@ -1295,7 +1295,7 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std::
break; break;
if( windowSize.width < minObjectSize.width || windowSize.height < minObjectSize.height ) if( windowSize.width < minObjectSize.width || windowSize.height < minObjectSize.height )
continue; continue;
int yStep; int yStep;
if( getFeatureType() == cv::FeatureEvaluator::HOG ) if( getFeatureType() == cv::FeatureEvaluator::HOG )
{ {
...@@ -1310,14 +1310,14 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std:: ...@@ -1310,14 +1310,14 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std::
{ {
UMat uscaledImage(uimageBuffer, Rect(0, 0, scaledImageSize.width, scaledImageSize.height)); UMat uscaledImage(uimageBuffer, Rect(0, 0, scaledImageSize.width, scaledImageSize.height));
resize( ugrayImage, uscaledImage, scaledImageSize, 0, 0, INTER_LINEAR ); resize( ugrayImage, uscaledImage, scaledImageSize, 0, 0, INTER_LINEAR );
if( ocl_detectSingleScale( uscaledImage, processingRectSize, yStep, factor, sumSize0 ) ) if( ocl_detectSingleScale( uscaledImage, processingRectSize, yStep, factor, sumSize0 ) )
continue; continue;
/////// if the OpenCL branch has been executed but failed, fall back to CPU: ///// /////// if the OpenCL branch has been executed but failed, fall back to CPU: /////
tryOpenCL = false; // for this cascade do not try OpenCL anymore tryOpenCL = false; // for this cascade do not try OpenCL anymore
// since we may already have some partial results from OpenCL code (unlikely, but still), // since we may already have some partial results from OpenCL code (unlikely, but still),
// we just recursively call the function again, but with tryOpenCL==false it will // we just recursively call the function again, but with tryOpenCL==false it will
// go with CPU route, so there is no infinite recursion // go with CPU route, so there is no infinite recursion
...@@ -1330,13 +1330,13 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std:: ...@@ -1330,13 +1330,13 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std::
{ {
Mat scaledImage( scaledImageSize, CV_8U, imageBuffer.data ); Mat scaledImage( scaledImageSize, CV_8U, imageBuffer.data );
resize( grayImage, scaledImage, scaledImageSize, 0, 0, INTER_LINEAR ); resize( grayImage, scaledImage, scaledImageSize, 0, 0, INTER_LINEAR );
if( !detectSingleScale( scaledImage, processingRectSize, yStep, factor, candidates, if( !detectSingleScale( scaledImage, processingRectSize, yStep, factor, candidates,
rejectLevels, levelWeights, sumSize0, outputRejectLevels ) ) rejectLevels, levelWeights, sumSize0, outputRejectLevels ) )
break; break;
} }
} }
if( use_ocl && tryOpenCL ) if( use_ocl && tryOpenCL )
{ {
Mat facepos = ufacepos.getMat(ACCESS_READ); Mat facepos = ufacepos.getMat(ACCESS_READ);
...@@ -1424,12 +1424,12 @@ void CascadeClassifierImpl::detectMultiScale( InputArray _image, std::vector<Rec ...@@ -1424,12 +1424,12 @@ void CascadeClassifierImpl::detectMultiScale( InputArray _image, std::vector<Rec
} }
} }
CascadeClassifierImpl::Data::Data() CascadeClassifierImpl::Data::Data()
{ {
stageType = featureType = ncategories = maxNodesPerTree = 0; stageType = featureType = ncategories = maxNodesPerTree = 0;
} }
bool CascadeClassifierImpl::Data::read(const FileNode &root) bool CascadeClassifierImpl::Data::read(const FileNode &root)
{ {
static const float THRESHOLD_EPS = 1e-5f; static const float THRESHOLD_EPS = 1e-5f;
...@@ -1503,7 +1503,7 @@ bool CascadeClassifierImpl::Data::read(const FileNode &root) ...@@ -1503,7 +1503,7 @@ bool CascadeClassifierImpl::Data::read(const FileNode &root)
DTree tree; DTree tree;
tree.nodeCount = (int)internalNodes.size()/nodeStep; tree.nodeCount = (int)internalNodes.size()/nodeStep;
maxNodesPerTree = std::max(maxNodesPerTree, tree.nodeCount); maxNodesPerTree = std::max(maxNodesPerTree, tree.nodeCount);
classifiers.push_back(tree); classifiers.push_back(tree);
nodes.reserve(nodes.size() + tree.nodeCount); nodes.reserve(nodes.size() + tree.nodeCount);
...@@ -1538,7 +1538,7 @@ bool CascadeClassifierImpl::Data::read(const FileNode &root) ...@@ -1538,7 +1538,7 @@ bool CascadeClassifierImpl::Data::read(const FileNode &root)
leaves.push_back((float)*internalNodesIter); leaves.push_back((float)*internalNodesIter);
} }
} }
if( isStumpBased() ) if( isStumpBased() )
{ {
int nodeOfs = 0, leafOfs = 0; int nodeOfs = 0, leafOfs = 0;
...@@ -1546,7 +1546,7 @@ bool CascadeClassifierImpl::Data::read(const FileNode &root) ...@@ -1546,7 +1546,7 @@ bool CascadeClassifierImpl::Data::read(const FileNode &root)
for( size_t stageIdx = 0; stageIdx < nstages; stageIdx++ ) for( size_t stageIdx = 0; stageIdx < nstages; stageIdx++ )
{ {
const Stage& stage = stages[stageIdx]; const Stage& stage = stages[stageIdx];
int ntrees = stage.ntrees; int ntrees = stage.ntrees;
for( int i = 0; i < ntrees; i++, nodeOfs++, leafOfs+= 2 ) for( int i = 0; i < ntrees; i++, nodeOfs++, leafOfs+= 2 )
{ {
...@@ -1560,7 +1560,7 @@ bool CascadeClassifierImpl::Data::read(const FileNode &root) ...@@ -1560,7 +1560,7 @@ bool CascadeClassifierImpl::Data::read(const FileNode &root)
return true; return true;
} }
bool CascadeClassifierImpl::read_(const FileNode& root) bool CascadeClassifierImpl::read_(const FileNode& root)
{ {
tryOpenCL = true; tryOpenCL = true;
......
...@@ -49,14 +49,14 @@ public: ...@@ -49,14 +49,14 @@ public:
protected: protected:
enum { SUM_ALIGN = 64 }; enum { SUM_ALIGN = 64 };
bool detectSingleScale( InputArray image, Size processingRectSize, bool detectSingleScale( InputArray image, Size processingRectSize,
int yStep, double factor, std::vector<Rect>& candidates, int yStep, double factor, std::vector<Rect>& candidates,
std::vector<int>& rejectLevels, std::vector<double>& levelWeights, std::vector<int>& rejectLevels, std::vector<double>& levelWeights,
Size sumSize0, bool outputRejectLevels = false ); Size sumSize0, bool outputRejectLevels = false );
bool ocl_detectSingleScale( InputArray image, Size processingRectSize, bool ocl_detectSingleScale( InputArray image, Size processingRectSize,
int yStep, double factor, Size sumSize0 ); int yStep, double factor, Size sumSize0 );
void detectMultiScaleNoGrouping( InputArray image, std::vector<Rect>& candidates, void detectMultiScaleNoGrouping( InputArray image, std::vector<Rect>& candidates,
std::vector<int>& rejectLevels, std::vector<double>& levelWeights, std::vector<int>& rejectLevels, std::vector<double>& levelWeights,
...@@ -109,19 +109,19 @@ protected: ...@@ -109,19 +109,19 @@ protected:
int ntrees; int ntrees;
float threshold; float threshold;
}; };
struct Stump struct Stump
{ {
Stump() {}; Stump() {};
Stump(int _featureIdx, float _threshold, float _left, float _right) Stump(int _featureIdx, float _threshold, float _left, float _right)
: featureIdx(_featureIdx), threshold(_threshold), left(_left), right(_right) {} : featureIdx(_featureIdx), threshold(_threshold), left(_left), right(_right) {}
int featureIdx; int featureIdx;
float threshold; float threshold;
float left; float left;
float right; float right;
}; };
Data(); Data();
bool read(const FileNode &node); bool read(const FileNode &node);
...@@ -151,7 +151,7 @@ protected: ...@@ -151,7 +151,7 @@ protected:
UMat ufacepos, ustages, ustumps, usubsets; UMat ufacepos, ustages, ustumps, usubsets;
ocl::Kernel cascadeKernel; ocl::Kernel cascadeKernel;
bool tryOpenCL; bool tryOpenCL;
Mutex mtx; Mutex mtx;
}; };
...@@ -240,7 +240,7 @@ protected: ...@@ -240,7 +240,7 @@ protected:
#define CALC_SUM_OFS_(p0, p1, p2, p3, ptr) \ #define CALC_SUM_OFS_(p0, p1, p2, p3, ptr) \
((ptr)[p0] - (ptr)[p1] - (ptr)[p2] + (ptr)[p3]) ((ptr)[p0] - (ptr)[p1] - (ptr)[p2] + (ptr)[p3])
#define CALC_SUM_OFS(rect, ptr) CALC_SUM_OFS_((rect)[0], (rect)[1], (rect)[2], (rect)[3], ptr) #define CALC_SUM_OFS(rect, ptr) CALC_SUM_OFS_((rect)[0], (rect)[1], (rect)[2], (rect)[3], ptr)
//---------------------------------------------- HaarEvaluator --------------------------------------- //---------------------------------------------- HaarEvaluator ---------------------------------------
...@@ -343,7 +343,7 @@ inline void HaarEvaluator::OptFeature :: setOffsets( const Feature& _f, int step ...@@ -343,7 +343,7 @@ inline void HaarEvaluator::OptFeature :: setOffsets( const Feature& _f, int step
weight[0] = _f.rect[0].weight; weight[0] = _f.rect[0].weight;
weight[1] = _f.rect[1].weight; weight[1] = _f.rect[1].weight;
weight[2] = _f.rect[2].weight; weight[2] = _f.rect[2].weight;
Rect r2 = weight[2] > 0 ? _f.rect[2].r : Rect(0,0,0,0); Rect r2 = weight[2] > 0 ? _f.rect[2].r : Rect(0,0,0,0);
if (_f.tilted) if (_f.tilted)
{ {
...@@ -615,7 +615,7 @@ inline int predictOrderedStump( CascadeClassifierImpl& cascade, ...@@ -615,7 +615,7 @@ inline int predictOrderedStump( CascadeClassifierImpl& cascade,
int nstages = (int)cascade.data.stages.size(); int nstages = (int)cascade.data.stages.size();
double tmp = 0; double tmp = 0;
for( int stageIdx = 0; stageIdx < nstages; stageIdx++ ) for( int stageIdx = 0; stageIdx < nstages; stageIdx++ )
{ {
const CascadeClassifierImpl::Data::Stage& stage = cascadeStages[stageIdx]; const CascadeClassifierImpl::Data::Stage& stage = cascadeStages[stageIdx];
...@@ -677,7 +677,7 @@ inline int predictCategoricalStump( CascadeClassifierImpl& cascade, ...@@ -677,7 +677,7 @@ inline int predictCategoricalStump( CascadeClassifierImpl& cascade,
sum = (double)tmp; sum = (double)tmp;
return -si; return -si;
} }
cascadeStumps += ntrees; cascadeStumps += ntrees;
cascadeSubsets += ntrees*subsetSize; cascadeSubsets += ntrees*subsetSize;
} }
......
...@@ -121,16 +121,15 @@ static bool convert(const String& oldcascade, const String& newcascade) ...@@ -121,16 +121,15 @@ static bool convert(const String& oldcascade, const String& newcascade)
FileNode sznode = oldroot[ICV_HAAR_SIZE_NAME]; FileNode sznode = oldroot[ICV_HAAR_SIZE_NAME];
if( sznode.empty() ) if( sznode.empty() )
return false; return false;
int maxdepth = 0;
Size cascadesize; Size cascadesize;
cascadesize.width = (int)sznode[0]; cascadesize.width = (int)sznode[0];
cascadesize.height = (int)sznode[1]; cascadesize.height = (int)sznode[1];
std::vector<HaarFeature> features; std::vector<HaarFeature> features;
size_t i, j, k, n; int i, j, k, n;
FileNode stages_seq = oldroot[ICV_HAAR_STAGES_NAME]; FileNode stages_seq = oldroot[ICV_HAAR_STAGES_NAME];
size_t nstages = stages_seq.size(); int nstages = (int)stages_seq.size();
std::vector<HaarStageClassifier> stages(nstages); std::vector<HaarStageClassifier> stages(nstages);
for( i = 0; i < nstages; i++ ) for( i = 0; i < nstages; i++ )
...@@ -139,14 +138,14 @@ static bool convert(const String& oldcascade, const String& newcascade) ...@@ -139,14 +138,14 @@ static bool convert(const String& oldcascade, const String& newcascade)
HaarStageClassifier& stage = stages[i]; HaarStageClassifier& stage = stages[i];
stage.threshold = (double)stagenode[ICV_HAAR_STAGE_THRESHOLD_NAME]; stage.threshold = (double)stagenode[ICV_HAAR_STAGE_THRESHOLD_NAME];
FileNode weaks_seq = stagenode[ICV_HAAR_TREES_NAME]; FileNode weaks_seq = stagenode[ICV_HAAR_TREES_NAME];
size_t nweaks = weaks_seq.size(); int nweaks = (int)weaks_seq.size();
stage.weaks.resize(nweaks); stage.weaks.resize(nweaks);
for( j = 0; j < nweaks; j++ ) for( j = 0; j < nweaks; j++ )
{ {
HaarClassifier& weak = stage.weaks[j]; HaarClassifier& weak = stage.weaks[j];
FileNode weaknode = weaks_seq[j]; FileNode weaknode = weaks_seq[j];
size_t nnodes = weaknode.size(); int nnodes = (int)weaknode.size();
for( n = 0; n < nnodes; n++ ) for( n = 0; n < nnodes; n++ )
{ {
...@@ -157,7 +156,7 @@ static bool convert(const String& oldcascade, const String& newcascade) ...@@ -157,7 +156,7 @@ static bool convert(const String& oldcascade, const String& newcascade)
node.f = (int)features.size(); node.f = (int)features.size();
f.tilted = (int)fnode[ICV_HAAR_TILTED_NAME] != 0; f.tilted = (int)fnode[ICV_HAAR_TILTED_NAME] != 0;
FileNode rects_seq = fnode[ICV_HAAR_RECTS_NAME]; FileNode rects_seq = fnode[ICV_HAAR_RECTS_NAME];
size_t nrects = rects_seq.size(); int nrects = (int)rects_seq.size();
for( k = 0; k < nrects; k++ ) for( k = 0; k < nrects; k++ )
{ {
...@@ -199,9 +198,9 @@ static bool convert(const String& oldcascade, const String& newcascade) ...@@ -199,9 +198,9 @@ static bool convert(const String& oldcascade, const String& newcascade)
if( !newfs.isOpened() ) if( !newfs.isOpened() )
return false; return false;
size_t maxWeakCount = 0, nfeatures = features.size(); int maxWeakCount = 0, nfeatures = (int)features.size();
for( i = 0; i < nstages; i++ ) for( i = 0; i < nstages; i++ )
maxWeakCount = std::max(maxWeakCount, stages[i].weaks.size()); maxWeakCount = std::max(maxWeakCount, (int)stages[i].weaks.size());
newfs << "cascade" << "{:opencv-cascade-classifier" newfs << "cascade" << "{:opencv-cascade-classifier"
<< "stageType" << "BOOST" << "stageType" << "BOOST"
...@@ -219,7 +218,7 @@ static bool convert(const String& oldcascade, const String& newcascade) ...@@ -219,7 +218,7 @@ static bool convert(const String& oldcascade, const String& newcascade)
for( i = 0; i < nstages; i++ ) for( i = 0; i < nstages; i++ )
{ {
size_t nweaks = stages[i].weaks.size(); int nweaks = (int)stages[i].weaks.size();
newfs << "{" << "maxWeakCount" << (int)nweaks newfs << "{" << "maxWeakCount" << (int)nweaks
<< "stageThreshold" << stages[i].threshold << "stageThreshold" << stages[i].threshold
<< "weakClassifiers" << "["; << "weakClassifiers" << "[";
...@@ -227,7 +226,7 @@ static bool convert(const String& oldcascade, const String& newcascade) ...@@ -227,7 +226,7 @@ static bool convert(const String& oldcascade, const String& newcascade)
{ {
const HaarClassifier& c = stages[i].weaks[j]; const HaarClassifier& c = stages[i].weaks[j];
newfs << "{" << "internalNodes" << "["; newfs << "{" << "internalNodes" << "[";
size_t nnodes = c.nodes.size(), nleaves = c.leaves.size(); int nnodes = (int)c.nodes.size(), nleaves = (int)c.leaves.size();
for( k = 0; k < nnodes; k++ ) for( k = 0; k < nnodes; k++ )
newfs << c.nodes[k].left << c.nodes[k].right newfs << c.nodes[k].left << c.nodes[k].right
<< c.nodes[k].f << c.nodes[k].threshold; << c.nodes[k].f << c.nodes[k].threshold;
...@@ -246,7 +245,7 @@ static bool convert(const String& oldcascade, const String& newcascade) ...@@ -246,7 +245,7 @@ static bool convert(const String& oldcascade, const String& newcascade)
{ {
const HaarFeature& f = features[i]; const HaarFeature& f = features[i];
newfs << "{" << "rects" << "["; newfs << "{" << "rects" << "[";
for( j = 0; j < (size_t)HaarFeature::RECT_NUM; j++ ) for( j = 0; j < HaarFeature::RECT_NUM; j++ )
{ {
if( j >= 2 && fabs(f.rect[j].weight) < FLT_EPSILON ) if( j >= 2 && fabs(f.rect[j].weight) < FLT_EPSILON )
break; break;
......
...@@ -44,7 +44,7 @@ __kernel void runHaarClassifierStump( ...@@ -44,7 +44,7 @@ __kernel void runHaarClassifierStump(
int iy = get_global_id(1)*xyscale; int iy = get_global_id(1)*xyscale;
sumstep /= sizeof(int); sumstep /= sizeof(int);
sqsumstep /= sizeof(int); sqsumstep /= sizeof(int);
if( ix < imgsize.x && iy < imgsize.y ) if( ix < imgsize.x && iy < imgsize.y )
{ {
int ntrees; int ntrees;
...@@ -52,7 +52,7 @@ __kernel void runHaarClassifierStump( ...@@ -52,7 +52,7 @@ __kernel void runHaarClassifierStump(
float s = 0.f; float s = 0.f;
__global const Stump* stump = stumps; __global const Stump* stump = stumps;
__global const OptFeature* f; __global const OptFeature* f;
__global const int* psum = sum + mad24(iy, sumstep, ix); __global const int* psum = sum + mad24(iy, sumstep, ix);
__global const int* pnsum = psum + mad24(normrect.y, sumstep, normrect.x); __global const int* pnsum = psum + mad24(normrect.y, sumstep, normrect.x);
int normarea = normrect.z * normrect.w; int normarea = normrect.z * normrect.w;
...@@ -64,7 +64,7 @@ __kernel void runHaarClassifierStump( ...@@ -64,7 +64,7 @@ __kernel void runHaarClassifierStump(
float4 weight, vsval; float4 weight, vsval;
int4 ofs, ofs0, ofs1, ofs2; int4 ofs, ofs0, ofs1, ofs2;
nf = nf > 0 ? nf : 1.f; nf = nf > 0 ? nf : 1.f;
for( stageIdx = 0; stageIdx < nstages; stageIdx++ ) for( stageIdx = 0; stageIdx < nstages; stageIdx++ )
{ {
ntrees = stages[stageIdx].ntrees; ntrees = stages[stageIdx].ntrees;
...@@ -73,7 +73,7 @@ __kernel void runHaarClassifierStump( ...@@ -73,7 +73,7 @@ __kernel void runHaarClassifierStump(
{ {
f = optfeatures + stump->featureIdx; f = optfeatures + stump->featureIdx;
weight = f->weight; weight = f->weight;
ofs = f->ofs[0]; ofs = f->ofs[0];
sval = (psum[ofs.x] - psum[ofs.y] - psum[ofs.z] + psum[ofs.w])*weight.x; sval = (psum[ofs.x] - psum[ofs.y] - psum[ofs.z] + psum[ofs.w])*weight.x;
ofs = f->ofs[1]; ofs = f->ofs[1];
...@@ -83,14 +83,14 @@ __kernel void runHaarClassifierStump( ...@@ -83,14 +83,14 @@ __kernel void runHaarClassifierStump(
ofs = f->ofs[2]; ofs = f->ofs[2];
sval += (psum[ofs.x] - psum[ofs.y] - psum[ofs.z] + psum[ofs.w])*weight.z; sval += (psum[ofs.x] - psum[ofs.y] - psum[ofs.z] + psum[ofs.w])*weight.z;
} }
s += (sval < stump->threshold*nf) ? stump->left : stump->right; s += (sval < stump->threshold*nf) ? stump->left : stump->right;
} }
if( s < stages[stageIdx].threshold ) if( s < stages[stageIdx].threshold )
break; break;
} }
if( stageIdx == nstages ) if( stageIdx == nstages )
{ {
int nfaces = atomic_inc(facepos); int nfaces = atomic_inc(facepos);
...@@ -128,7 +128,7 @@ __kernel void runLBPClassifierStump( ...@@ -128,7 +128,7 @@ __kernel void runLBPClassifierStump(
int iy = get_global_id(1)*xyscale; int iy = get_global_id(1)*xyscale;
sumstep /= sizeof(int); sumstep /= sizeof(int);
sqsumstep /= sizeof(int); sqsumstep /= sizeof(int);
if( ix < imgsize.x && iy < imgsize.y ) if( ix < imgsize.x && iy < imgsize.y )
{ {
int ntrees; int ntrees;
...@@ -137,7 +137,7 @@ __kernel void runLBPClassifierStump( ...@@ -137,7 +137,7 @@ __kernel void runLBPClassifierStump(
__global const Stump* stump = stumps; __global const Stump* stump = stumps;
__global const int* bitset = bitsets; __global const int* bitset = bitsets;
__global const OptFeature* f; __global const OptFeature* f;
__global const int* psum = sum + mad24(iy, sumstep, ix); __global const int* psum = sum + mad24(iy, sumstep, ix);
__global const int* pnsum = psum + mad24(normrect.y, sumstep, normrect.x); __global const int* pnsum = psum + mad24(normrect.y, sumstep, normrect.x);
int normarea = normrect.z * normrect.w; int normarea = normrect.z * normrect.w;
...@@ -149,7 +149,7 @@ __kernel void runLBPClassifierStump( ...@@ -149,7 +149,7 @@ __kernel void runLBPClassifierStump(
float4 weight; float4 weight;
int4 ofs; int4 ofs;
nf = nf > 0 ? nf : 1.f; nf = nf > 0 ? nf : 1.f;
for( stageIdx = 0; stageIdx < nstages; stageIdx++ ) for( stageIdx = 0; stageIdx < nstages; stageIdx++ )
{ {
ntrees = stages[stageIdx].ntrees; ntrees = stages[stageIdx].ntrees;
...@@ -157,17 +157,17 @@ __kernel void runLBPClassifierStump( ...@@ -157,17 +157,17 @@ __kernel void runLBPClassifierStump(
for( i = 0; i < ntrees; i++, stump++, bitset += bitsetSize ) for( i = 0; i < ntrees; i++, stump++, bitset += bitsetSize )
{ {
f = optfeatures + stump->featureIdx; f = optfeatures + stump->featureIdx;
weight = f->weight; weight = f->weight;
// compute LBP feature to val // compute LBP feature to val
s += (bitset[val >> 5] & (1 << (val & 31))) ? stump->left : stump->right; s += (bitset[val >> 5] & (1 << (val & 31))) ? stump->left : stump->right;
} }
if( s < stages[stageIdx].threshold ) if( s < stages[stageIdx].threshold )
break; break;
} }
if( stageIdx == nstages ) if( stageIdx == nstages )
{ {
int nfaces = atomic_inc(facepos); int nfaces = atomic_inc(facepos);
...@@ -183,4 +183,3 @@ __kernel void runLBPClassifierStump( ...@@ -183,4 +183,3 @@ __kernel void runLBPClassifierStump(
} }
} }
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment