From 05cd88ae4233824a31072e1ed692ba80604ff51f Mon Sep 17 00:00:00 2001 From: "marina.kolpakova" Date: Mon, 26 Nov 2012 18:50:08 +0400 Subject: [PATCH] clean code; fix problems in documentation --- modules/gpu/doc/object_detection.rst | 6 ++-- modules/gpu/include/opencv2/gpu/gpu.hpp | 4 ++- modules/gpu/perf/perf_softcascade.cpp | 35 ----------------------- modules/gpu/src/cuda/icf-sc.cu | 2 +- modules/gpu/src/icf.hpp | 8 +----- modules/gpu/src/softcascade.cpp | 2 +- modules/gpu/test/test_softcascade.cpp | 50 --------------------------------- 7 files changed, 9 insertions(+), 98 deletions(-) diff --git a/modules/gpu/doc/object_detection.rst b/modules/gpu/doc/object_detection.rst index c503d93..ce18892 100644 --- a/modules/gpu/doc/object_detection.rst +++ b/modules/gpu/doc/object_detection.rst @@ -200,7 +200,7 @@ The function is mainly used to learn the classifier. Soft Cascade Classifier -====================== +========================== Soft Cascade Classifier for Object Detection ---------------------------------------------------------- @@ -226,7 +226,7 @@ The sample has been rejected if it fall rejection threshold. So stageless cascad SCascade ---------------- -.. ocv:class:: SCascade +.. ocv:class:: SCascade : public Algorithm Implementation of soft (stageless) cascaded detector. :: @@ -248,7 +248,7 @@ Implementation of soft (stageless) cascaded detector. :: virtual ~SCascade(); virtual bool load(const FileNode& fn); virtual void detect(InputArray image, InputArray rois, OutputArray objects, Stream& stream = Stream::Null()) const; - void genRoi(InputArray roi, OutputArray mask, Stream& stream = Stream::Null()) const; + virtual void genRoi(InputArray roi, OutputArray mask, Stream& stream = Stream::Null()) const; }; diff --git a/modules/gpu/include/opencv2/gpu/gpu.hpp b/modules/gpu/include/opencv2/gpu/gpu.hpp index 8362282..f0a9e99 100644 --- a/modules/gpu/include/opencv2/gpu/gpu.hpp +++ b/modules/gpu/include/opencv2/gpu/gpu.hpp @@ -1586,7 +1586,7 @@ public: // There non zero value mean that detector should be executed in this point. // Param mask is an output mask // Param stream is stream is a high-level CUDA stream abstraction used for asynchronous execution - void genRoi(InputArray roi, OutputArray mask, Stream& stream = Stream::Null()) const; + virtual void genRoi(InputArray roi, OutputArray mask, Stream& stream = Stream::Null()) const; private: @@ -1600,6 +1600,8 @@ private: int rejCriteria; }; +CV_EXPORTS bool initModule_gpu(void); + ////////////////////////////////// SURF ////////////////////////////////////////// class CV_EXPORTS SURF_GPU diff --git a/modules/gpu/perf/perf_softcascade.cpp b/modules/gpu/perf/perf_softcascade.cpp index 3e82cc5..ae816bc 100644 --- a/modules/gpu/perf/perf_softcascade.cpp +++ b/modules/gpu/perf/perf_softcascade.cpp @@ -33,18 +33,6 @@ namespace { else if (a.w != b.w) return a.w < b.w; else return a.h < b.h; } - - // bool operator()(const cv::SoftCascade::Detection& a, - // const cv::SoftCascade::Detection& b) const - // { - // const cv::Rect& ra = a.rect; - // const cv::Rect& rb = b.rect; - - // if (ra.x != rb.x) return ra.x < rb.x; - // else if (ra.y != rb.y) return ra.y < rb.y; - // else if (ra.width != rb.width) return ra.width < rb.width; - // else return ra.height < rb.height; - // } }; cv::Mat sortDetections(cv::gpu::GpuMat& objects) @@ -99,29 +87,6 @@ RUN_GPU(SCascadeTest, detect) NO_CPU(SCascadeTest, detect) -// RUN_CPU(SCascadeTest, detect) -// { -// cv::Mat colored = readImage(GET_PARAM(1)); -// ASSERT_FALSE(colored.empty()); - -// cv::SCascade cascade; -// ASSERT_TRUE(cascade.load(getDataPath(GET_PARAM(0)))); - -// std::vector rois; - -// typedef cv::SCascade::Detection Detection; -// std::vectorobjects; -// cascade.detectMultiScale(colored, rois, objects); - -// TEST_CYCLE() -// { -// cascade.detectMultiScale(colored, rois, objects); -// } - -// std::sort(objects.begin(), objects.end(), DetectionLess()); -// SANITY_CHECK(objects); -// } - static cv::Rect getFromTable(int idx) { static const cv::Rect rois[] = diff --git a/modules/gpu/src/cuda/icf-sc.cu b/modules/gpu/src/cuda/icf-sc.cu index e323799..5fca87b 100644 --- a/modules/gpu/src/cuda/icf-sc.cu +++ b/modules/gpu/src/cuda/icf-sc.cu @@ -49,7 +49,7 @@ namespace cv { namespace gpu { namespace device { namespace icf { - // ToDo: use textures or ancached load instruction. + // ToDo: use textures or uncached load instruction. __global__ void magToHist(const uchar* __restrict__ mag, const float* __restrict__ angle, const int angPitch, uchar* __restrict__ hog, const int hogPitch, const int fh) diff --git a/modules/gpu/src/icf.hpp b/modules/gpu/src/icf.hpp index 06f99f2..295255f 100644 --- a/modules/gpu/src/icf.hpp +++ b/modules/gpu/src/icf.hpp @@ -45,7 +45,6 @@ #define __OPENCV_ICF_HPP__ #include -#include #if defined __CUDACC__ # define __device __device__ __forceinline__ @@ -93,12 +92,7 @@ struct __align__(8) Node enum { THRESHOLD_MASK = 0x0FFFFFFF }; - Node(const uchar4 r, const uint ch, const uint t) : rect(r), threshold(t + (ch << 28)) - { - // printf("%d\n", t); - // printf("[%d %d %d %d] %d, %d\n",rect.x, rect.y, rect.z, rect.w, (int)(threshold >> 28), - // (int)(0x0FFFFFFF & threshold)); - } + Node(const uchar4 r, const uint ch, const uint t) : rect(r), threshold(t + (ch << 28)) {} }; struct __align__(16) Detection diff --git a/modules/gpu/src/softcascade.cpp b/modules/gpu/src/softcascade.cpp index 37e7e3f..2208369 100644 --- a/modules/gpu/src/softcascade.cpp +++ b/modules/gpu/src/softcascade.cpp @@ -142,7 +142,7 @@ struct cv::gpu::SCascade::Fields static const char * const SC_F_RECT = "rect"; FileNode fn = root[SC_OCTAVES]; - if (fn.empty()) return false; + if (fn.empty()) return false; using namespace device::icf; diff --git a/modules/gpu/test/test_softcascade.cpp b/modules/gpu/test/test_softcascade.cpp index da97d41..40bf5a0 100644 --- a/modules/gpu/test/test_softcascade.cpp +++ b/modules/gpu/test/test_softcascade.cpp @@ -205,56 +205,6 @@ GPU_TEST_P(SCascadeTestRoi, detect, } -// typedef ::testing::TestWithParam > SCascadeTestLevel; -// GPU_TEST_P(SCascadeTestLevel, detect, -// testing::Combine( -// ALL_DEVICES, -// testing::Values(std::string("cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml")), -// testing::Values(std::string("../cv/cascadeandhog/bahnhof/image_00000000_0.png")), -// testing::Range(0, 47) -// )) -// { -// cv::gpu::setDevice(GET_PARAM(0).deviceID()); - -// cv::gpu::SCascade cascade; - -// cv::FileStorage fs(perf::TestBase::getDataPath(GET_PARAM(1)), cv::FileStorage::READ); -// ASSERT_TRUE(fs.isOpened()); - -// ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode())); - -// cv::Mat coloredCpu = cv::imread(cvtest::TS::ptr()->get_data_path() + GET_PARAM(2)); -// ASSERT_FALSE(coloredCpu.empty()); - -// typedef cv::gpu::SCascade::Detection Detection; -// GpuMat colored(coloredCpu), objectBoxes(1, 100 * sizeof(Detection), CV_8UC1), rois(colored.size(), CV_8UC1); -// rois.setTo(1); - -// cv::gpu::GpuMat trois; -// cascade.genRoi(rois, trois); -// objectBoxes.setTo(0); -// int level = GET_PARAM(3); -// cascade.detect(colored, trois, objectBoxes, level); - -// cv::Mat dt(objectBoxes); - -// Detection* dts = ((Detection*)dt.data) + 1; -// int* count = dt.ptr(0); - -// cv::Mat result(coloredCpu); - -// printTotal(std::cout, *count); -// for (int i = 0; i < *count; ++i) -// { -// Detection d = dts[i]; -// print(std::cout, d); -// cv::rectangle(result, cv::Rect(d.x, d.y, d.w, d.h), cv::Scalar(255, 0, 0, 255), 1); -// } - -// writeResult(result, level); -// SHOW(result); -// } - TEST(SCascadeTest, readCascade) { std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/icf-template.xml"; -- 2.7.4