From: marina.kolpakova Date: Thu, 11 Oct 2012 13:05:23 +0000 (+0400) Subject: refactor preprocessing X-Git-Tag: submit/tizen_ivi/20141117.190038~2^2~1214^2~59^2~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=916ba4c0ea1493c6883e45d990a85421f975a60b;p=profile%2Fivi%2Fopencv.git refactor preprocessing --- diff --git a/modules/gpu/src/softcascade.cpp b/modules/gpu/src/softcascade.cpp index 8fa8286..c93949f 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