Merge commit '43aec5ad' into merge-2.4
[platform/upstream/opencv.git] / modules / softcascade / doc / softcascade_detector.rst
1 Soft Cascade Classifier
2 =======================
3
4 .. highlight:: cpp
5
6 Soft Cascade Classifier for Object Detection
7 --------------------------------------------
8
9 Cascade detectors have been shown to operate extremely rapidly, with high accuracy, and have important applications in different spheres. The initial goal for this cascade implementation was the fast and accurate pedestrian detector but it also useful in general. Soft cascade is trained with AdaBoost. But instead of training sequence of stages, the soft cascade is trained as a one long stage of T weak classifiers. Soft cascade is formulated as follows:
10
11 .. math::
12     \texttt{H}(x) = \sum _{\texttt{t}=1..\texttt{T}} {\texttt{s}_t(x)}
13
14 where :math:`\texttt{s}_t(x) = \alpha_t\texttt{h}_t(x)` are the set of thresholded weak classifiers selected during AdaBoost training scaled by the associated weights. Let
15
16 .. math::
17     \texttt{H}_t(x) = \sum _{\texttt{i}=1..\texttt{t}} {\texttt{s}_i(x)}
18
19 be the partial sum of sample responses before :math:`t`-the weak classifier will be applied. The function :math:`\texttt{H}_t(x)` of :math:`t` for sample :math:`x` named *sample trace*.
20 After each weak classifier evaluation, the sample trace at the point :math:`t` is compared with the rejection threshold :math:`r_t`. The sequence of :math:`r_t` named *rejection trace*.
21
22 The sample has been rejected if it fall rejection threshold. So stageless cascade allows to reject not-object sample as soon as possible. Another meaning of the sample trace is a confidence with that sample recognized as desired object. At each :math:`t` that confidence depend on all previous weak classifier. This feature of soft cascade is resulted in more accurate detection. The original formulation of soft cascade can be found in [BJ05]_.
23
24 .. [BJ05] Lubomir Bourdev and Jonathan Brandt. tRobust Object Detection Via Soft Cascade. IEEE CVPR, 2005.
25 .. [BMTG12] Rodrigo Benenson, Markus Mathias, Radu Timofte and Luc Van Gool. Pedestrian detection at 100 frames per second. IEEE CVPR, 2012.
26
27
28 softcascade::Detector
29 ---------------------
30 .. ocv:class:: softcascade::Detector : public Algorithm
31
32 Implementation of soft (stageless) cascaded detector. ::
33
34     class Detector : public Algorithm
35     {
36     public:
37
38         enum { NO_REJECT = 1, DOLLAR = 2, /*PASCAL = 4,*/ DEFAULT = NO_REJECT};
39
40         Detector(double minScale = 0.4, double maxScale = 5., int scales = 55, int rejCriteria = 1);
41         virtual ~Detector();
42         cv::AlgorithmInfo* info() const;
43         virtual bool load(const FileNode& fileNode);
44         virtual void read(const FileNode& fileNode);
45         virtual void detect(InputArray image, InputArray rois, std::vector<Detection>& objects) const;
46         virtual void detect(InputArray image, InputArray rois, OutputArray rects, OutputArray confs) const;
47
48     }
49
50
51
52 softcascade::Detector::Detector
53 ----------------------------------------
54 An empty cascade will be created.
55
56 .. ocv:function:: softcascade::Detector::Detector( double minScale=0.4, double maxScale=5., int scales=55, int rejCriteria=1 )
57
58 .. ocv:pyfunction:: cv2.softcascade_Detector([minScale[, maxScale[, scales[, rejCriteria]]]]) -> <softcascade_Detector object>
59
60     :param minScale: a minimum scale relative to the original size of the image on which cascade will be applied.
61
62     :param maxScale: a maximum scale relative to the original size of the image on which cascade will be applied.
63
64     :param scales: a number of scales from minScale to maxScale.
65
66     :param rejCriteria: algorithm used for non maximum suppression.
67
68
69
70 softcascade::Detector::~Detector
71 -----------------------------------------
72 Destructor for Detector.
73
74 .. ocv:function:: softcascade::Detector::~Detector()
75
76
77
78 softcascade::Detector::load
79 ---------------------------
80 Load cascade from FileNode.
81
82 .. ocv:function:: bool softcascade::Detector::load(const FileNode& fileNode)
83
84 .. ocv:pyfunction:: cv2.softcascade_Detector.load(fileNode) -> retval
85
86     :param fileNode: File node from which the soft cascade are read.
87
88
89
90 softcascade::Detector::detect
91 -----------------------------
92 Apply cascade to an input frame and return the vector of Detection objects.
93
94 .. ocv:function:: void softcascade::Detector::detect(InputArray image, InputArray rois, std::vector<Detection>& objects) const
95
96 .. ocv:function:: void softcascade::Detector::detect(InputArray image, InputArray rois, OutputArray rects, OutputArray confs) const
97
98 .. ocv:pyfunction:: cv2.softcascade_Detector.detect(image, rois[, rects[, confs]]) -> rects, confs
99
100     :param image: a frame on which detector will be applied.
101
102     :param rois: a vector of regions of interest. Only the objects that fall into one of the regions will be returned.
103
104     :param objects: an output array of Detections.
105
106     :param rects: an output array of bounding rectangles for detected objects.
107
108     :param confs: an output array of confidence for detected objects. i-th bounding rectangle corresponds i-th confidence.
109
110
111 softcascade::ChannelFeatureBuilder
112 ----------------------------------
113 .. ocv:class:: softcascade::ChannelFeatureBuilder : public Algorithm
114
115 Public interface for of soft (stageless) cascaded detector. ::
116
117     class ChannelFeatureBuilder : public Algorithm
118     {
119     public:
120         virtual ~ChannelFeatureBuilder();
121
122         virtual void operator()(InputArray src, OutputArray channels) const = 0;
123
124         static cv::Ptr<ChannelFeatureBuilder> create();
125     };
126
127
128 softcascade::ChannelFeatureBuilder:~ChannelFeatureBuilder
129 ---------------------------------------------------------
130 Destructor for ChannelFeatureBuilder.
131
132 .. ocv:function:: softcascade::ChannelFeatureBuilder::~ChannelFeatureBuilder()
133
134 .. ocv:pyfunction:: cv2.softcascade_ChannelFeatureBuilder_create(featureType) -> retval
135
136
137 softcascade::ChannelFeatureBuilder::operator()
138 ----------------------------------------------
139 Create channel feature integrals for input image.
140
141 .. ocv:function:: void softcascade::ChannelFeatureBuilder::operator()(InputArray src, OutputArray channels) const
142
143 .. ocv:pyfunction:: cv2.softcascade_ChannelFeatureBuilder.compute(src, channels) -> None
144
145     :param src source frame
146
147     :param channels in OutputArray of computed channels