clean code; fix problems in documentation
authormarina.kolpakova <marina.kolpakova@itseez.com>
Mon, 26 Nov 2012 14:50:08 +0000 (18:50 +0400)
committermarina.kolpakova <marina.kolpakova@itseez.com>
Mon, 26 Nov 2012 14:50:08 +0000 (18:50 +0400)
modules/gpu/doc/object_detection.rst
modules/gpu/include/opencv2/gpu/gpu.hpp
modules/gpu/perf/perf_softcascade.cpp
modules/gpu/src/cuda/icf-sc.cu
modules/gpu/src/icf.hpp
modules/gpu/src/softcascade.cpp
modules/gpu/test/test_softcascade.cpp

index c503d93..ce18892 100644 (file)
@@ -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;
     };
 
 
index 8362282..f0a9e99 100644 (file)
@@ -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
index 3e82cc5..ae816bc 100644 (file)
@@ -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<cv::Rect> rois;
-
-//     typedef cv::SCascade::Detection Detection;
-//     std::vector<Detection>objects;
-//     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[] =
index e323799..5fca87b 100644 (file)
@@ -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)
index 06f99f2..295255f 100644 (file)
@@ -45,7 +45,6 @@
 #define __OPENCV_ICF_HPP__
 
 #include <opencv2/gpu/device/common.hpp>
-#include <stdio.h>
 
 #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
index 37e7e3f..2208369 100644 (file)
@@ -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;
 
index da97d41..40bf5a0 100644 (file)
@@ -205,56 +205,6 @@ GPU_TEST_P(SCascadeTestRoi, detect,
 
 }
 
-// typedef ::testing::TestWithParam<std::tr1::tuple<cv::gpu::DeviceInfo, std::string, std::string, int> > 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<int>(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";