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
4b161803
Commit
4b161803
authored
Aug 07, 2015
by
Vlad Shakhuro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Warning fixes
parent
81d44b7e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
19 deletions
+19
-19
detector.cpp
modules/xobjdetect/src/detector.cpp
+7
-7
features.cpp
modules/xobjdetect/src/features.cpp
+1
-1
waldboost.cpp
modules/xobjdetect/src/waldboost.cpp
+11
-11
No files found.
modules/xobjdetect/src/detector.cpp
View file @
4b161803
...
...
@@ -60,12 +60,12 @@ static vector<Mat> sample_patches(
const
string
&
path
,
int
n_rows
,
int
n_cols
,
in
t
n_patches
)
size_
t
n_patches
)
{
vector
<
String
>
filenames
;
glob
(
path
,
filenames
);
vector
<
Mat
>
patches
;
in
t
patch_count
=
0
;
size_
t
patch_count
=
0
;
for
(
size_t
i
=
0
;
i
<
filenames
.
size
();
++
i
)
{
Mat
img
=
imread
(
filenames
[
i
],
CV_LOAD_IMAGE_GRAYSCALE
);
for
(
int
row
=
0
;
row
+
n_rows
<
img
.
rows
;
row
+=
n_rows
)
{
...
...
@@ -116,7 +116,7 @@ void WBDetector::train(
const
int
stage_neg
=
5000
;
const
int
max_per_image
=
25
;
const
float
scales_arr
[]
=
{
.3
,
.4
,
.5
,
.6
,
.7
,
.8
,
.9
,
1
};
const
float
scales_arr
[]
=
{
.3
f
,
.4
f
,
.5
f
,
.6
f
,
.7
f
,
.8
f
,
.9
f
,
1.0
f
};
const
vector
<
float
>
scales
(
scales_arr
,
scales_arr
+
sizeof
(
scales_arr
)
/
sizeof
(
*
scales_arr
));
...
...
@@ -129,8 +129,8 @@ void WBDetector::train(
cerr
<<
"compute features"
<<
endl
;
pos_data
=
Mat1b
(
n_features
,
pos_imgs
.
size
());
neg_data
=
Mat1b
(
n_features
,
neg_imgs
.
size
());
pos_data
=
Mat1b
(
n_features
,
(
int
)
pos_imgs
.
size
());
neg_data
=
Mat1b
(
n_features
,
(
int
)
neg_imgs
.
size
());
for
(
size_t
k
=
0
;
k
<
pos_imgs
.
size
();
++
k
)
{
eval
->
setImage
(
pos_imgs
[
k
],
+
1
,
0
,
boost
.
get_feature_indices
());
...
...
@@ -142,7 +142,7 @@ void WBDetector::train(
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
);
neg_data
.
at
<
uchar
>
(
j
,
(
int
)
k
)
=
(
*
eval
)(
j
);
}
}
...
...
@@ -201,7 +201,7 @@ void WBDetector::detect(
bboxes
.
clear
();
confidences
.
clear
();
vector
<
float
>
scales
;
for
(
float
scale
=
0.2
f
;
scale
<
1.2
f
;
scale
*=
1.1
)
{
for
(
float
scale
=
0.2
f
;
scale
<
1.2
f
;
scale
*=
1.1
f
)
{
scales
.
push_back
(
scale
);
}
Ptr
<
CvFeatureParams
>
params
=
CvFeatureParams
::
create
();
...
...
modules/xobjdetect/src/features.cpp
View file @
4b161803
...
...
@@ -114,7 +114,7 @@ void CvFeatureEvaluator::init(const CvFeatureParams *_featureParams,
generateFeatures
();
}
void
CvFeatureEvaluator
::
setImage
(
const
Mat
&
,
uchar
clsLabel
,
int
idx
,
const
std
::
vector
<
int
>&
feature_ind
)
void
CvFeatureEvaluator
::
setImage
(
const
Mat
&
,
uchar
clsLabel
,
int
idx
,
const
std
::
vector
<
int
>&
)
{
//CV_Assert(img.cols == winSize.width);
//CV_Assert(img.rows == winSize.height);
...
...
modules/xobjdetect/src/waldboost.cpp
View file @
4b161803
...
...
@@ -84,7 +84,7 @@ static void compute_min_step(const Mat &data_pos, const Mat &data_neg, size_t n_
max
(
reduced_pos
,
reduced_neg
,
data_max
);
data_max
+=
0.01
;
data_step
=
(
data_max
-
data_min
)
/
(
n_bins
-
1
);
data_step
=
(
data_max
-
data_min
)
/
(
double
)(
n_bins
-
1
);
}
static
void
quantize_data
(
Mat
&
data
,
Mat1f
&
data_min
,
Mat1f
&
data_step
)
...
...
@@ -132,15 +132,15 @@ void WaldBoost::detect(Ptr<CvFeatureEvaluator> eval,
float
scale
=
scales
[
i
];
resize
(
img
,
resized_img
,
Size
(),
scale
,
scale
);
eval
->
setImage
(
resized_img
,
0
,
0
,
feature_indices_
);
int
n_rows
=
24
/
scale
;
int
n_cols
=
24
/
scale
;
int
n_rows
=
(
int
)(
24
/
scale
)
;
int
n_cols
=
(
int
)(
24
/
scale
)
;
for
(
int
r
=
0
;
r
+
24
<
resized_img
.
rows
;
r
+=
step
)
{
for
(
int
c
=
0
;
c
+
24
<
resized_img
.
cols
;
c
+=
step
)
{
//eval->setImage(resized_img(Rect(c, r, 24, 24)), 0, 0);
eval
->
setWindow
(
Point
(
c
,
r
));
if
(
predict
(
eval
,
&
h
)
==
+
1
)
{
int
row
=
r
/
scale
;
int
col
=
c
/
scale
;
int
row
=
(
int
)(
r
/
scale
)
;
int
col
=
(
int
)(
c
/
scale
)
;
bboxes
.
push_back
(
Rect
(
col
,
row
,
n_cols
,
n_rows
));
confidences
.
push_back
(
h
);
}
...
...
@@ -164,14 +164,14 @@ void WaldBoost::detect(Ptr<CvFeatureEvaluator> eval,
float
scale
=
scales
[
i
];
resize
(
img
,
resized_img
,
Size
(),
scale
,
scale
);
eval
->
setImage
(
resized_img
,
0
,
0
,
feature_indices_
);
int
n_rows
=
24
/
scale
;
int
n_cols
=
24
/
scale
;
int
n_rows
=
(
int
)(
24
/
scale
)
;
int
n_cols
=
(
int
)(
24
/
scale
)
;
for
(
int
r
=
0
;
r
+
24
<
resized_img
.
rows
;
r
+=
step
)
{
for
(
int
c
=
0
;
c
+
24
<
resized_img
.
cols
;
c
+=
step
)
{
eval
->
setWindow
(
Point
(
c
,
r
));
if
(
predict
(
eval
,
&
h
)
==
+
1
)
{
int
row
=
r
/
scale
;
int
col
=
c
/
scale
;
int
row
=
(
int
)(
r
/
scale
)
;
int
col
=
(
int
)(
c
/
scale
)
;
bboxes
.
push_back
(
Rect
(
col
,
row
,
n_cols
,
n_rows
));
confidences
.
push_back
(
h
);
}
...
...
@@ -233,7 +233,7 @@ void WaldBoost::fit(Mat& data_pos, Mat& data_neg)
compute_cdf
(
data_pos
.
row
(
feat_i
),
pos_weights
,
pos_cdf
);
compute_cdf
(
data_neg
.
row
(
feat_i
),
neg_weights
,
neg_cdf
);
float
neg_total
=
sum
(
neg_weights
)[
0
];
float
neg_total
=
(
float
)
sum
(
neg_weights
)[
0
];
Mat1f
err_direct
=
pos_cdf
+
neg_total
-
neg_cdf
;
Mat1f
err_backward
=
1.0
f
-
err_direct
;
...
...
@@ -265,7 +265,7 @@ void WaldBoost::fit(Mat& data_pos, Mat& data_neg)
}
float
alpha
=
.5
f
*
log
((
1
-
min_err
)
/
min_err
);
float
alpha
=
.5
f
*
(
float
)
log
((
1
-
min_err
)
/
min_err
);
alphas_
.
push_back
(
alpha
);
feature_indices_
.
push_back
(
min_feature_ind
);
thresholds_
.
push_back
(
min_threshold
);
...
...
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