From: marina.kolpakova Date: Wed, 5 Sep 2012 14:29:13 +0000 (+0400) Subject: add apply cascade method X-Git-Tag: submit/tizen_ivi/20141117.190038~2^2~1245^2~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c04725b6812902c16e8027787365e66be5ac16ae;p=profile%2Fivi%2Fopencv.git add apply cascade method --- diff --git a/modules/gpu/CMakeLists.txt b/modules/gpu/CMakeLists.txt index 580e7df..78aafcf 100644 --- a/modules/gpu/CMakeLists.txt +++ b/modules/gpu/CMakeLists.txt @@ -15,10 +15,10 @@ file(GLOB lib_cuda_hdrs "src/cuda/*.hpp" "src/cuda/*.h") file(GLOB lib_srcs "src/*.cpp") file(GLOB lib_cuda "src/cuda/*.cu*") -source_group("Include" FILES ${lib_hdrs}) -source_group("Src\\Host" FILES ${lib_srcs} ${lib_int_hdrs}) -source_group("Src\\Cuda" FILES ${lib_cuda} ${lib_cuda_hdrs}) -source_group("Device" FILES ${lib_device_hdrs}) +source_group("Include" FILES ${lib_hdrs}) +source_group("Src\\Host" FILES ${lib_srcs} ${lib_int_hdrs}) +source_group("Src\\Cuda" FILES ${lib_cuda} ${lib_cuda_hdrs}) +source_group("Device" FILES ${lib_device_hdrs}) source_group("Device\\Detail" FILES ${lib_device_hdrs_detail}) if (HAVE_CUDA) diff --git a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp index 0ef391d..9fab741 100644 --- a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp +++ b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp @@ -507,7 +507,6 @@ public: int step = 4, int rejectfactor = 1); protected: - virtual void detectInRoi(); virtual void detectForOctave(int octave); // virtual bool detectSingleScale( const Mat& image, int stripCount, Size processingRectSize, // int stripSize, int yStep, double factor, vector& candidates, diff --git a/modules/objdetect/src/softcascade.cpp b/modules/objdetect/src/softcascade.cpp index cace667..fa94052 100644 --- a/modules/objdetect/src/softcascade.cpp +++ b/modules/objdetect/src/softcascade.cpp @@ -164,6 +164,15 @@ namespace { float relScale() {return (factor / octave); } }; + + struct Integral + { + cv::Mat magnitude; + std::vector hist; + cv::Mat luv; + + Integral(cv::Mat m, std::vector h, cv::Mat l) : magnitude(m), hist(h), luv(l) {} + }; } struct cv::SoftCascade::Filds @@ -181,6 +190,26 @@ struct cv::SoftCascade::Filds std::vector features; std::vector levels; + typedef std::vector::iterator stIter_t; + + // carrently roi must be save for out of ranges. + void detectInRoi(const cv::Rect& roi, const Integral& ints, std::vector& objects, const int step) + { + for (int dy = roi.y; dy < roi.height; dy+=step) + for (int dx = roi.x; dx < roi.width; dx += step) + { + applyCascade(ints, dx, dy); + } + } + + void applyCascade(const Integral& ints, const int x, const int y) + { + for (stIter_t sIt = sIt.begin(); sIt != stages.end(); ++sIt) + { + Stage stage& = *sIt; + } + } + // compute levels of full pyramid void calcLevels(int frameW, int frameH, int scales) { @@ -327,7 +356,7 @@ bool cv::SoftCascade::load( const string& filename, const float minScale, const namespace { - void calcHistBins(const cv::Mat& grey, std::vector& histInts, const int bins) + void calcHistBins(const cv::Mat& grey, cv::Mat magIntegral, std::vector& histInts, const int bins) { CV_Assert( grey.type() == CV_8U); const int rows = grey.rows + 1; @@ -368,18 +397,10 @@ namespace { histInts.push_back(sum); } - cv::Mat magIntegral; cv::integral(mag, magIntegral, mag.depth()); } - - struct Integrals - { - /* data */ - }; } -void cv::SoftCascade::detectInRoi() -{} void cv::SoftCascade::detectMultiScale(const Mat& image, const std::vector& rois, std::vector& objects, @@ -405,13 +426,16 @@ void cv::SoftCascade::detectMultiScale(const Mat& image, const std::vector hist; + cv::Mat magnitude; const int bins = 6; - calcHistBins(grey, hist, bins); + calcHistBins(grey, magnitude, hist, bins); + + Integral integrals(magnitude, hist, luv); for (RIter_t it = rois.begin(); it != rois.end(); ++it) { const cv::Rect& roi = *it; - // detectInRoi(roi, objects, step); + (*filds).detectInRoi(roi, integrals, objects, step); } } diff --git a/modules/objdetect/test/test_softcascade.cpp b/modules/objdetect/test/test_softcascade.cpp index d283d06..bb02a09 100644 --- a/modules/objdetect/test/test_softcascade.cpp +++ b/modules/objdetect/test/test_softcascade.cpp @@ -62,8 +62,8 @@ TEST(SoftCascade, Detect) std::vector objectBoxes; std::vector rois; rois.push_back(cv::Rect(0, 0, 640, 480)); - ASSERT_NO_THROW( - { + // ASSERT_NO_THROW( + // { cascade.detectMultiScale(colored, rois, objectBoxes); - }); + // }); } \ No newline at end of file