Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
a01f5964
Commit
a01f5964
authored
Jan 29, 2013
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update documentation for softcascade module
parent
7f80054d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
173 additions
and
46 deletions
+173
-46
fpool.cpp
apps/sft/fpool.cpp
+4
-4
config.hpp
apps/sft/include/sft/config.hpp
+5
-5
sft.cpp
apps/sft/sft.cpp
+2
-2
softcascade_detector.rst
modules/softcascade/doc/softcascade_detector.rst
+74
-26
softcascade_training.rst
modules/softcascade/doc/softcascade_training.rst
+81
-2
soft_cascade_octave.cpp
modules/softcascade/src/soft_cascade_octave.cpp
+7
-7
No files found.
apps/sft/fpool.cpp
View file @
a01f5964
...
...
@@ -197,7 +197,7 @@ namespace {
using
namespace
sft
;
void
glob
(
const
string
&
refRoot
,
const
string
&
refExt
,
svector
&
refvecFiles
)
{
std
::
string
strFilePath
;
// Filepath
std
::
string
strFilePath
;
// File
path
std
::
string
strExtension
;
// Extension
std
::
string
strPattern
=
refRoot
+
"
\\
*.*"
;
...
...
@@ -240,14 +240,14 @@ void glob(const string& refRoot, const string& refExt, svector &refvecFiles)
#endif
// in the default case data folders should be al
l
igned as following:
// in the default case data folders should be aligned as following:
// 1. positives: <train or test path>/octave_<octave number>/pos/*.png
// 2. negatives: <train or test path>/octave_<octave number>/neg/*.png
ScaledDataset
::
ScaledDataset
(
const
string
&
path
,
const
int
oct
)
{
dprintf
(
"%s
\n
"
,
"get dataset file names..."
);
dprintf
(
"%s
\n
"
,
"Positives glob
b
ing..."
);
dprintf
(
"%s
\n
"
,
"Positives globing..."
);
#if !defined (_WIN32) && ! defined(__MINGW32__)
glob
(
path
+
"/pos/octave_"
+
itoa
(
oct
)
+
"/*.png"
,
pos
);
...
...
@@ -255,7 +255,7 @@ ScaledDataset::ScaledDataset(const string& path, const int oct)
glob
(
path
+
"/pos/octave_"
+
itoa
(
oct
),
"png"
,
pos
);
#endif
dprintf
(
"%s
\n
"
,
"Negatives glob
b
ing..."
);
dprintf
(
"%s
\n
"
,
"Negatives globing..."
);
#if !defined (_WIN32) && ! defined(__MINGW32__)
glob
(
path
+
"/neg/octave_"
+
itoa
(
oct
)
+
"/*.png"
,
neg
);
#else
...
...
apps/sft/include/sft/config.hpp
View file @
a01f5964
...
...
@@ -93,7 +93,7 @@ struct Config
// List of octaves for which have to be trained cascades (a list of powers of two)
ivector
octaves
;
// Maximum number of positives that should be
i
sed during training
// Maximum number of positives that should be
u
sed during training
int
positives
;
// Initial number of negatives used during training.
...
...
@@ -102,10 +102,10 @@ struct Config
// Number of weak negatives to add each bootstrapping step.
int
btpNegatives
;
// Inverse of scale for feature res
a
zing
// Inverse of scale for feature res
i
zing
int
shrinkage
;
// Depth on weak classifier's de
sit
ion tree
// Depth on weak classifier's de
cis
ion tree
int
treeDepth
;
// Weak classifiers number in resulted cascade
...
...
@@ -120,10 +120,10 @@ struct Config
// path to resulting cascade
string
outXmlPath
;
// seed for
f
andom generation
// seed for
r
andom generation
int
seed
;
// // bounding re
tangle for actual exe
mple into example window
// // bounding re
ctangle for actual exa
mple into example window
// cv::Rect exampleWindow;
};
...
...
apps/sft/sft.cpp
View file @
a01f5964
...
...
@@ -40,7 +40,7 @@
//
//M*/
// Tra
t
ing application for Soft Cascades.
// Tra
in
ing application for Soft Cascades.
#include <sft/common.hpp>
#include <iostream>
...
...
@@ -114,7 +114,7 @@ int main(int argc, char** argv)
// 3. Train all octaves
for
(
ivector
::
const_iterator
it
=
cfg
.
octaves
.
begin
();
it
!=
cfg
.
octaves
.
end
();
++
it
)
{
// a. create ran
g
om feature pool
// a. create ran
d
om feature pool
int
nfeatures
=
cfg
.
poolSize
;
cv
::
Size
model
=
cfg
.
model
(
it
);
std
::
cout
<<
"Model "
<<
model
<<
std
::
endl
;
...
...
modules/softcascade/doc/softcascade_detector.rst
View file @
a01f5964
...
...
@@ -25,29 +25,37 @@ The sample has been rejected if it fall rejection threshold. So stageless cascad
.. [BMTG12] Rodrigo Benenson, Markus Mathias, Radu Timofte and Luc Van Gool. Pedestrian detection at 100 frames per second. IEEE CVPR, 2012.
S
Cascade
----------------
.. ocv:class:: S
Cascade
S
oftCascadeDetector
----------------
---
.. ocv:class:: S
oftCascadeDetector
Implementation of soft (stageless) cascaded detector. ::
class CV_EXPORTS
SCascade
: public Algorithm
class CV_EXPORTS
_W SoftCascadeDetector
: public Algorithm
{
public:
SCascade(const float minScale = 0.4f, const float maxScale = 5.f, const int scales = 55, const int rejfactor = 1);
virtual ~SCascade();
enum { NO_REJECT = 1, DOLLAR = 2, /*PASCAL = 4,*/ DEFAULT = NO_REJECT};
CV_WRAP SoftCascadeDetector(double minScale = 0.4, double maxScale = 5., int scales = 55, int rejCriteria = 1);
CV_WRAP virtual ~SoftCascadeDetector();
cv::AlgorithmInfo* info() const;
virtual bool load(const FileNode& fn);
CV_WRAP virtual bool load(const FileNode& fileNode);
CV_WRAP virtual void read(const FileNode& fileNode);
virtual void detect(InputArray image, InputArray rois, std::vector<Detection>& objects) const;
virtual void detect(InputArray image, InputArray rois, OutputArray rects, OutputArray confs) const;
};
CV_WRAP virtual void detect(InputArray image, InputArray rois, CV_OUT OutputArray rects, CV_OUT OutputArray confs) const;
}
SCascade::SCascade
--------------------------
SoftCascadeDetector::SoftCascadeDetector
----------------------------------------
An empty cascade will be created.
.. ocv:function:: bool SCascade::SCascade(const float minScale = 0.4f, const float maxScale = 5.f, const int scales = 55, const int rejfactor = 1)
.. ocv:function:: SoftCascadeDetector::SoftCascadeDetector(float minScale = 0.4f, float maxScale = 5.f, int scales = 55, int rejCriteria = 1)
.. ocv:pyfunction:: cv2.SoftCascadeDetector.SoftCascadeDetector(minScale[, maxScale[, scales[, rejCriteria]]]) -> cascade
:param minScale: a minimum scale relative to the original size of the image on which cascade will be applied.
...
...
@@ -55,35 +63,39 @@ An empty cascade will be created.
:param scales: a number of scales from minScale to maxScale.
:param rej
factor:
used for non maximum suppression.
:param rej
Criteria: algorithm
used for non maximum suppression.
S
Cascade::~SCascade
---------------------------
Destructor for S
Cascade
.
S
oftCascadeDetector::~SoftCascadeDetector
---------------------------
--------------
Destructor for S
oftCascadeDetector
.
.. ocv:function:: S
Cascade::~SCascade
()
.. ocv:function:: S
oftCascadeDetector::~SoftCascadeDetector
()
S
Cascade
::load
S
oftCascadeDetector
::load
--------------------------
Load cascade from FileNode.
.. ocv:function:: bool S
Cascade::load(const FileNode& fn
)
.. ocv:function:: bool S
oftCascadeDetector::load(const FileNode& fileNode
)
:param fn: File node from which the soft cascade are read.
.. ocv:pyfunction:: cv2.SoftCascadeDetector.load(fileNode)
:param fileNode: File node from which the soft cascade are read.
SCascade::detect
--------------------------
SoftCascadeDetector::detect
---------------------------
Apply cascade to an input frame and return the vector of Detection objects.
.. ocv:function:: void SCascade::detect(InputArray image, InputArray rois, std::vector<Detection>& objects) const
.. ocv:function:: void SoftCascadeDetector::detect(InputArray image, InputArray rois, std::vector<Detection>& objects) const
.. ocv:function:: void SoftCascadeDetector::detect(InputArray image, InputArray rois, OutputArray rects, OutputArray confs) const
.. ocv:
function:: void SCascade::detect(InputArray image, InputArray rois, OutputArray rects, OutputArray confs) const
.. ocv:
pyfunction:: cv2.SoftCascadeDetector.detect(image, rois) -> (rects, confs)
:param image: a frame on which detector will be applied.
...
...
@@ -93,4 +105,41 @@ Apply cascade to an input frame and return the vector of Detection objects.
:param rects: an output array of bounding rectangles for detected objects.
:param confs: an output array of confidence for detected objects. i-th bounding rectangle corresponds i-th confidence.
\ No newline at end of file
:param confs: an output array of confidence for detected objects. i-th bounding rectangle corresponds i-th confidence.
ChannelFeatureBuilder
---------------------
.. ocv:class:: ChannelFeatureBuilder
Public interface for of soft (stageless) cascaded detector. ::
class CV_EXPORTS_W ChannelFeatureBuilder : public Algorithm
{
public:
virtual ~ChannelFeatureBuilder();
CV_WRAP_AS(compute) virtual void operator()(InputArray src, CV_OUT OutputArray channels) const = 0;
CV_WRAP static cv::Ptr<ChannelFeatureBuilder> create();
};
ChannelFeatureBuilder:~ChannelFeatureBuilder
--------------------------------------------
Destructor for ChannelFeatureBuilder.
.. ocv:function:: ChannelFeatureBuilder::~ChannelFeatureBuilder()
ChannelFeatureBuilder::operator()
---------------------------------
Create channel feature integrals for input image.
.. ocv:function:: void ChannelFeatureBuilder::operator()(InputArray src, OutputArray channels) const
.. ocv:pyfunction:: cv2.ChannelFeatureBuilder.compute(src, channels) -> None
:param src source frame
:param channels in OutputArray of computed channels
modules/softcascade/doc/softcascade_training.rst
View file @
a01f5964
Soft Cascade Training
=======================
\ No newline at end of file
=======================
.. highlight:: cpp
Soft Cascade Detector Training
--------------------------------------------
SoftCascadeOctave
-----------------
.. ocv:class:: SoftCascadeOctave
Public interface for soft cascade training algorithm
class CV_EXPORTS SoftCascadeOctave : public Algorithm
{
public:
enum {
// Direct backward pruning. (Cha Zhang and Paul Viola)
DBP = 1,
// Multiple instance pruning. (Cha Zhang and Paul Viola)
MIP = 2,
// Originally proposed by L. Bourdev and J. Brandt
HEURISTIC = 4 };
virtual ~SoftCascadeOctave();
static cv::Ptr<SoftCascadeOctave> create(cv::Rect boundingBox, int npositives, int nnegatives, int logScale, int shrinkage);
virtual bool train(const Dataset* dataset, const FeaturePool* pool, int weaks, int treeDepth) = 0;
virtual void setRejectThresholds(OutputArray thresholds) = 0;
virtual void write( cv::FileStorage &fs, const FeaturePool* pool, InputArray thresholds) const = 0;
virtual void write( CvFileStorage* fs, string name) const = 0;
};
SoftCascadeOctave::~SoftCascadeOctave
---------------------------------------
Destructor for SoftCascadeOctave.
.. ocv:function:: SoftCascadeOctave::~SoftCascadeOctave()
SoftCascadeOctave::train
------------------------
.. ocv:function:: bool SoftCascadeOctave::train(const Dataset* dataset, const FeaturePool* pool, int weaks, int treeDepth)
:param dataset an object that allows communicate for training set.
:param pool an object that presents feature pool.
:param weaks a number of weak trees should be trained.
:param treeDepth a depth of resulting weak trees.
SoftCascadeOctave::setRejectThresholds
--------------------------------------
.. ocv:function:: void SoftCascadeOctave::setRejectThresholds(OutputArray thresholds)
:param thresholds an output array of resulted rejection vector. Have same size as number of trained stages.
SoftCascadeOctave::write
------------------------
.. ocv:function:: write SoftCascadeOctave::train(cv::FileStorage &fs, const FeaturePool* pool, InputArray thresholds) const
.. ocv:function:: write SoftCascadeOctave::train( CvFileStorage* fs, string name) const
:param fs an output file storage to store trained detector.
:param pool an object that presents feature pool.
:param dataset a rejection vector that should be included in detector xml file.
:param name a name of root node for trained detector.
modules/softcascade/src/soft_cascade_octave.cpp
View file @
a01f5964
...
...
@@ -11,7 +11,7 @@
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2008-201
2
, Willow Garage Inc., all rights reserved.
// Copyright (C) 2008-201
3
, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
...
...
@@ -22,7 +22,7 @@
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and
/
or other materials provided with the distribution.
// and
/
or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
...
...
@@ -216,7 +216,7 @@ void BoostedSoftCascadeOctave::setRejectThresholds(cv::OutputArray _thresholds)
{
dprintf
(
"set thresholds according to DBP strategy
\n
"
);
// labels de
s
ided by classifier
// labels de
c
ided by classifier
cv
::
Mat
desisions
(
responses
.
cols
,
responses
.
rows
,
responses
.
type
());
float
*
dptr
=
desisions
.
ptr
<
float
>
(
0
);
...
...
@@ -423,7 +423,7 @@ void BoostedSoftCascadeOctave::write( cv::FileStorage &fso, const FeaturePool* p
<<
"scale"
<<
logScale
<<
"weaks"
<<
weak
->
total
<<
"trees"
<<
"["
;
// should be repla
s
ed with the H.L. one
// should be repla
c
ed with the H.L. one
CvSeqReader
reader
;
cvStartReadSeq
(
weak
,
&
reader
);
...
...
@@ -463,7 +463,7 @@ bool BoostedSoftCascadeOctave::train(const Dataset* dataset, const FeaturePool*
processPositives
(
dataset
,
pool
);
generateNegatives
(
dataset
,
pool
);
// 2. only s
u
mple case (all features used)
// 2. only s
i
mple case (all features used)
int
nfeatures
=
pool
->
size
();
cv
::
Mat
varIdx
(
1
,
nfeatures
,
CV_32SC1
);
int
*
ptr
=
varIdx
.
ptr
<
int
>
(
0
);
...
...
@@ -471,7 +471,7 @@ bool BoostedSoftCascadeOctave::train(const Dataset* dataset, const FeaturePool*
for
(
int
x
=
0
;
x
<
nfeatures
;
++
x
)
ptr
[
x
]
=
x
;
// 3. only s
u
mple case (all samples used)
// 3. only s
i
mple case (all samples used)
int
nsamples
=
npositives
+
nnegatives
;
cv
::
Mat
sampleIdx
(
1
,
nsamples
,
CV_32SC1
);
ptr
=
sampleIdx
.
ptr
<
int
>
(
0
);
...
...
@@ -479,7 +479,7 @@ bool BoostedSoftCascadeOctave::train(const Dataset* dataset, const FeaturePool*
for
(
int
x
=
0
;
x
<
nsamples
;
++
x
)
ptr
[
x
]
=
x
;
// 4. ICF has an order
able responc
e.
// 4. ICF has an order
ed respons
e.
cv
::
Mat
varType
(
1
,
nfeatures
+
1
,
CV_8UC1
);
uchar
*
uptr
=
varType
.
ptr
<
uchar
>
(
0
);
for
(
int
x
=
0
;
x
<
nfeatures
;
++
x
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment