diff --git a/modules/gpu/src/softcascade.cpp b/modules/gpu/src/softcascade.cpp index 8fa82867fc..c93949f1c7 100644 --- a/modules/gpu/src/softcascade.cpp +++ b/modules/gpu/src/softcascade.cpp @@ -183,13 +183,47 @@ struct cv::gpu::SoftCascade::Filds { cudaMemset(plane.data, 0, plane.step * plane.rows); - int fw = Filds::FRAME_WIDTH; - int fh = Filds::FRAME_HEIGHT; + static const int fw = Filds::FRAME_WIDTH; + static const int fh = Filds::FRAME_HEIGHT; GpuMat gray(plane, cv::Rect(0, fh * Filds::HOG_LUV_BINS, fw, fh)); cv::gpu::cvtColor(colored, gray, CV_BGR2GRAY); + createHogBins(gray); + + createLuvBins(colored); + + integrate(); + } + +private: + void calcLevels(const std::vector& octs, + int frameW, int frameH, int nscales); + + typedef std::vector::const_iterator octIt_t; + int fitOctave(const std::vector& octs, const float& logFactor) const + { + float minAbsLog = FLT_MAX; + int res = 0; + for (int oct = 0; oct < (int)octs.size(); ++oct) + { + const device::icf::Octave& octave =octs[oct]; + float logOctave = ::log(octave.scale); + float logAbsScale = ::fabs(logFactor - logOctave); + + if(logAbsScale < minAbsLog) + { + res = oct; + minAbsLog = logAbsScale; + } + } + return res; + } + + void createHogBins(const cv::gpu::GpuMat& gray) + { + static const int fw = Filds::FRAME_WIDTH; + static const int fh = Filds::FRAME_HEIGHT; - //create hog GpuMat dfdx(fplane, cv::Rect(0, 0, fw, fh)); GpuMat dfdy(fplane, cv::Rect(0, fh, fw, fh)); @@ -213,7 +247,14 @@ struct cv::gpu::SoftCascade::Filds GpuMat cmag(plane, cv::Rect(0, fh * Filds::HOG_BINS, fw, fh)); nmag.convertTo(cmag, CV_8UC1); - // create luv + device::icf::fillBins(plane, nang, fw, fh, Filds::HOG_BINS); + } + + void createLuvBins(const cv::gpu::GpuMat& colored) + { + static const int fw = Filds::FRAME_WIDTH; + static const int fh = Filds::FRAME_HEIGHT; + cv::gpu::cvtColor(colored, luv, CV_BGR2Luv); std::vector splited; @@ -223,8 +264,12 @@ struct cv::gpu::SoftCascade::Filds } cv::gpu::split(luv, splited); + } - device::icf::fillBins(plane, nang, fw, fh, Filds::HOG_BINS); + void integrate() + { + int fw = Filds::FRAME_WIDTH; + int fh = Filds::FRAME_HEIGHT; GpuMat channels(plane, cv::Rect(0, 0, fw, fh * Filds::HOG_LUV_BINS)); cv::gpu::resize(channels, shrunk, cv::Size(), 0.25, 0.25, CV_INTER_AREA); @@ -239,30 +284,6 @@ struct cv::gpu::SoftCascade::Filds cv::gpu::integralBuffered(channel, sum, integralBuffer); } } - -private: - void calcLevels(const std::vector& octs, - int frameW, int frameH, int nscales); - - typedef std::vector::const_iterator octIt_t; - int fitOctave(const std::vector& octs, const float& logFactor) const - { - float minAbsLog = FLT_MAX; - int res = 0; - for (int oct = 0; oct < (int)octs.size(); ++oct) - { - const device::icf::Octave& octave =octs[oct]; - float logOctave = ::log(octave.scale); - float logAbsScale = ::fabs(logFactor - logOctave); - - if(logAbsScale < minAbsLog) - { - res = oct; - minAbsLog = logAbsScale; - } - } - return res; - } }; bool cv::gpu::SoftCascade::Filds::fill(const FileNode &root, const float mins, const float maxs) @@ -572,5 +593,4 @@ cv::Size cv::gpu::SoftCascade::getRoiSize() const return cv::Size(Filds::FRAME_WIDTH / 4, Filds::FRAME_HEIGHT / 4); } - #endif \ No newline at end of file