Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
81d44b7e
Commit
81d44b7e
authored
Aug 07, 2015
by
Vlad Shakhuro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix warnings
parent
d06d7e29
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
18 deletions
+17
-18
detector.cpp
modules/xobjdetect/src/detector.cpp
+6
-6
features.cpp
modules/xobjdetect/src/features.cpp
+3
-3
lbpfeatures.h
modules/xobjdetect/src/lbpfeatures.h
+4
-4
traincascade_features.h
modules/xobjdetect/src/traincascade_features.h
+3
-3
waldboost.cpp
modules/xobjdetect/src/waldboost.cpp
+1
-1
waldboost_detector.cpp
...objdetect/tools/waldboost_detector/waldboost_detector.cpp
+0
-1
No files found.
modules/xobjdetect/src/detector.cpp
View file @
81d44b7e
...
...
@@ -107,8 +107,8 @@ void WBDetector::train(
int
n_features
;
Mat
pos_data
,
neg_data
;
Ptr
<
CvFeatureEvaluator
>
eval
=
CvFeatureEvaluator
::
create
(
CvFeatureParams
::
LBP
);
eval
->
init
(
CvFeatureParams
::
create
(
CvFeatureParams
::
LBP
),
1
,
Size
(
24
,
24
));
Ptr
<
CvFeatureEvaluator
>
eval
=
CvFeatureEvaluator
::
create
();
eval
->
init
(
CvFeatureParams
::
create
(),
1
,
Size
(
24
,
24
));
n_features
=
eval
->
getNumFeatures
();
const
int
stages
[]
=
{
32
,
64
,
128
,
256
,
512
,
1024
,
2048
,
4096
};
...
...
@@ -135,14 +135,14 @@ void WBDetector::train(
for
(
size_t
k
=
0
;
k
<
pos_imgs
.
size
();
++
k
)
{
eval
->
setImage
(
pos_imgs
[
k
],
+
1
,
0
,
boost
.
get_feature_indices
());
for
(
int
j
=
0
;
j
<
n_features
;
++
j
)
{
pos_data
.
at
<
uchar
>
(
j
,
k
)
=
(
*
eval
)(
j
,
0
);
pos_data
.
at
<
uchar
>
(
j
,
k
)
=
(
*
eval
)(
j
);
}
}
for
(
size_t
k
=
0
;
k
<
neg_imgs
.
size
();
++
k
)
{
eval
->
setImage
(
neg_imgs
[
k
],
0
,
0
,
boost
.
get_feature_indices
());
for
(
int
j
=
0
;
j
<
n_features
;
++
j
)
{
neg_data
.
at
<
uchar
>
(
j
,
k
)
=
(
*
eval
)(
j
,
0
);
neg_data
.
at
<
uchar
>
(
j
,
k
)
=
(
*
eval
)(
j
);
}
}
...
...
@@ -204,8 +204,8 @@ void WBDetector::detect(
for
(
float
scale
=
0.2
f
;
scale
<
1.2
f
;
scale
*=
1.1
)
{
scales
.
push_back
(
scale
);
}
Ptr
<
CvFeatureParams
>
params
=
CvFeatureParams
::
create
(
CvFeatureParams
::
LBP
);
Ptr
<
CvFeatureEvaluator
>
eval
=
CvFeatureEvaluator
::
create
(
CvFeatureParams
::
LBP
);
Ptr
<
CvFeatureParams
>
params
=
CvFeatureParams
::
create
();
Ptr
<
CvFeatureEvaluator
>
eval
=
CvFeatureEvaluator
::
create
();
eval
->
init
(
params
,
1
,
Size
(
24
,
24
));
boost
.
detect
(
eval
,
img
,
scales
,
bboxes
,
confidences
);
assert
(
confidences
.
size
()
==
bboxes
.
size
());
...
...
modules/xobjdetect/src/features.cpp
View file @
81d44b7e
...
...
@@ -96,7 +96,7 @@ bool CvFeatureParams::read( const FileNode &node )
return
(
maxCatCount
>=
0
&&
featSize
>=
1
);
}
Ptr
<
CvFeatureParams
>
CvFeatureParams
::
create
(
int
featureType
)
Ptr
<
CvFeatureParams
>
CvFeatureParams
::
create
()
{
return
Ptr
<
CvFeatureParams
>
(
new
CvLBPFeatureParams
);
}
...
...
@@ -114,7 +114,7 @@ void CvFeatureEvaluator::init(const CvFeatureParams *_featureParams,
generateFeatures
();
}
void
CvFeatureEvaluator
::
setImage
(
const
Mat
&
img
,
uchar
clsLabel
,
int
idx
,
const
std
::
vector
<
int
>&
feature_ind
)
void
CvFeatureEvaluator
::
setImage
(
const
Mat
&
,
uchar
clsLabel
,
int
idx
,
const
std
::
vector
<
int
>&
feature_ind
)
{
//CV_Assert(img.cols == winSize.width);
//CV_Assert(img.rows == winSize.height);
...
...
@@ -122,7 +122,7 @@ void CvFeatureEvaluator::setImage(const Mat &img, uchar clsLabel, int idx, const
cls
.
ptr
<
float
>
(
idx
)[
0
]
=
clsLabel
;
}
Ptr
<
CvFeatureEvaluator
>
CvFeatureEvaluator
::
create
(
int
type
)
Ptr
<
CvFeatureEvaluator
>
CvFeatureEvaluator
::
create
()
{
return
Ptr
<
CvFeatureEvaluator
>
(
new
CvLBPEvaluator
);
}
modules/xobjdetect/src/lbpfeatures.h
View file @
81d44b7e
...
...
@@ -64,8 +64,8 @@ public:
virtual
void
setImage
(
const
cv
::
Mat
&
img
,
uchar
clsLabel
,
int
idx
,
const
std
::
vector
<
int
>
&
feature_ind
);
virtual
void
setWindow
(
const
cv
::
Point
&
p
)
{
cur_sum
=
sum
.
rowRange
(
p
.
y
,
p
.
y
+
winSize
.
height
).
colRange
(
p
.
x
,
p
.
x
+
winSize
.
width
);
}
virtual
float
operator
()(
int
featureIdx
,
int
sampleIdx
)
{
return
(
float
)
features
[
featureIdx
].
calc
(
cur_sum
,
offset_
,
sampleIdx
);
}
virtual
float
operator
()(
int
featureIdx
)
{
return
(
float
)
features
[
featureIdx
].
calc
(
cur_sum
);
}
virtual
void
writeFeatures
(
cv
::
FileStorage
&
fs
,
const
cv
::
Mat
&
featureMap
)
const
;
protected
:
virtual
void
generateFeatures
();
...
...
@@ -75,7 +75,7 @@ protected:
public
:
Feature
();
Feature
(
int
offset
,
int
x
,
int
y
,
int
_block_w
,
int
_block_h
);
uchar
calc
(
const
cv
::
Mat
&
_sum
,
int
offset
,
size_t
y
);
uchar
calc
(
const
cv
::
Mat
&
_sum
);
void
write
(
cv
::
FileStorage
&
fs
)
const
;
cv
::
Rect
rect
;
...
...
@@ -90,7 +90,7 @@ protected:
int
offset_
;
};
inline
uchar
CvLBPEvaluator
::
Feature
::
calc
(
const
cv
::
Mat
&
_sum
,
int
offset
,
size_t
y
)
inline
uchar
CvLBPEvaluator
::
Feature
::
calc
(
const
cv
::
Mat
&
_sum
)
{
const
int
*
psum
=
_sum
.
ptr
<
int
>
();
...
...
modules/xobjdetect/src/traincascade_features.h
View file @
81d44b7e
...
...
@@ -110,7 +110,7 @@ public:
virtual
void
init
(
const
CvFeatureParams
&
fp
);
virtual
void
write
(
cv
::
FileStorage
&
fs
)
const
;
virtual
bool
read
(
const
cv
::
FileNode
&
node
);
static
cv
::
Ptr
<
CvFeatureParams
>
create
(
int
featureType
);
static
cv
::
Ptr
<
CvFeatureParams
>
create
();
int
maxCatCount
;
// 0 in case of numerical features
int
featSize
;
// 1 in case of simple features (HAAR, LBP) and N_BINS(9)*N_CELLS(4) in case of Dalal's HOG features
};
...
...
@@ -124,8 +124,8 @@ public:
virtual
void
setImage
(
const
cv
::
Mat
&
img
,
uchar
clsLabel
,
int
idx
,
const
std
::
vector
<
int
>
&
feature_ind
);
virtual
void
setWindow
(
const
cv
::
Point
&
p
)
=
0
;
virtual
void
writeFeatures
(
cv
::
FileStorage
&
fs
,
const
cv
::
Mat
&
featureMap
)
const
=
0
;
virtual
float
operator
()(
int
featureIdx
,
int
sampleIdx
)
=
0
;
static
cv
::
Ptr
<
CvFeatureEvaluator
>
create
(
int
type
);
virtual
float
operator
()(
int
featureIdx
)
=
0
;
static
cv
::
Ptr
<
CvFeatureEvaluator
>
create
();
int
getNumFeatures
()
const
{
return
numFeatures
;
}
int
getMaxCatCount
()
const
{
return
featureParams
->
maxCatCount
;
}
...
...
modules/xobjdetect/src/waldboost.cpp
View file @
81d44b7e
...
...
@@ -317,7 +317,7 @@ int WaldBoost::predict(Ptr<CvFeatureEvaluator> eval, float *h) const
assert
(
feature_indices_
.
size
()
==
size_t
(
weak_count_
));
float
res
=
0
;
for
(
int
i
=
0
;
i
<
weak_count_
;
++
i
)
{
float
val
=
(
*
eval
)(
feature_indices_
[
i
]
,
0
);
float
val
=
(
*
eval
)(
feature_indices_
[
i
]);
int
label
=
polarities_
[
i
]
*
(
val
-
thresholds_
[
i
])
>
0
?
+
1
:
-
1
;
res
+=
alphas_
[
i
]
*
label
;
if
(
res
<
THR
)
{
...
...
modules/xobjdetect/tools/waldboost_detector/waldboost_detector.cpp
View file @
81d44b7e
...
...
@@ -30,4 +30,3 @@ int main(int argc, char **argv)
imwrite
(
argv
[
4
],
img
);
}
}
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