Soft Cascade Classifier
-======================
+==========================
Soft Cascade Classifier for Object Detection
----------------------------------------------------------
SCascade
----------------
-.. ocv:class:: SCascade
+.. ocv:class:: SCascade : public Algorithm
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;
};
// 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:
int rejCriteria;
};
+CV_EXPORTS bool initModule_gpu(void);
+
////////////////////////////////// SURF //////////////////////////////////////////
class CV_EXPORTS SURF_GPU
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)
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[] =
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)
#define __OPENCV_ICF_HPP__
#include <opencv2/gpu/device/common.hpp>
-#include <stdio.h>
#if defined __CUDACC__
# define __device __device__ __forceinline__
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
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;
}
-// 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";