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
d8b0e8d5
Commit
d8b0e8d5
authored
Jun 27, 2014
by
Vlad Shakhuro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix MS compiler warnings
parent
27692f5c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
20 deletions
+20
-20
xobjdetect.hpp
modules/xobjdetect/include/opencv2/xobjdetect.hpp
+1
-1
acffeature.cpp
modules/xobjdetect/src/acffeature.cpp
+5
-5
icfdetector.cpp
modules/xobjdetect/src/icfdetector.cpp
+7
-7
stump.cpp
modules/xobjdetect/src/stump.cpp
+4
-4
waldboost.cpp
modules/xobjdetect/src/waldboost.cpp
+3
-3
No files found.
modules/xobjdetect/include/opencv2/xobjdetect.hpp
View file @
d8b0e8d5
...
...
@@ -109,7 +109,7 @@ struct CV_EXPORTS WaldBoostParams
int
weak_count
;
float
alpha
;
WaldBoostParams
()
:
weak_count
(
100
),
alpha
(
0.01
)
WaldBoostParams
()
:
weak_count
(
100
),
alpha
(
0.01
f
)
{}
};
...
...
modules/xobjdetect/src/acffeature.cpp
View file @
d8b0e8d5
...
...
@@ -83,7 +83,7 @@ void ACFFeatureEvaluator::setChannels(cv::InputArrayOfArrays channels)
int
sum
=
0
;
for
(
int
cell_row
=
row
;
cell_row
<
row
+
4
;
++
cell_row
)
for
(
int
cell_col
=
col
;
cell_col
<
col
+
4
;
++
cell_col
)
sum
+=
channel
.
at
<
float
>
(
cell_row
,
cell_col
);
sum
+=
(
int
)
channel
.
at
<
float
>
(
cell_row
,
cell_col
);
acf_channel
(
row
/
4
,
col
/
4
)
=
sum
;
}
...
...
@@ -99,8 +99,8 @@ void ACFFeatureEvaluator::setPosition(Size position)
void
ACFFeatureEvaluator
::
evaluateAll
(
OutputArray
feature_values
)
const
{
Mat_
<
int
>
feature_vals
(
1
,
features_
.
size
());
for
(
size_t
i
=
0
;
i
<
features_
.
size
();
++
i
)
Mat_
<
int
>
feature_vals
(
1
,
(
int
)
features_
.
size
());
for
(
int
i
=
0
;
i
<
(
int
)
features_
.
size
();
++
i
)
{
feature_vals
(
0
,
i
)
=
evaluate
(
i
);
}
...
...
@@ -146,13 +146,13 @@ void computeChannels(cv::InputArray image, cv::OutputArrayOfArrays channels_)
magnitude
(
row_der
,
col_der
,
grad
);
Mat_
<
Vec6f
>
hist
(
grad
.
rows
,
grad
.
cols
);
const
float
to_deg
=
180
/
3.1415926
;
const
float
to_deg
=
180
/
3.1415926
f
;
for
(
int
row
=
0
;
row
<
grad
.
rows
;
++
row
)
{
for
(
int
col
=
0
;
col
<
grad
.
cols
;
++
col
)
{
float
angle
=
atan2
(
row_der
(
row
,
col
),
col_der
(
row
,
col
))
*
to_deg
;
if
(
angle
<
0
)
angle
+=
180
;
int
ind
=
angle
/
30
;
int
ind
=
(
int
)(
angle
/
30
)
;
hist
(
row
,
col
)[
ind
]
=
grad
(
row
,
col
);
}
}
...
...
modules/xobjdetect/src/icfdetector.cpp
View file @
d8b0e8d5
...
...
@@ -68,7 +68,7 @@ void ICFDetector::train(const vector<string>& image_filenames,
vector
<
Mat
>
samples
;
/* positive samples + negative samples */
Mat
sample
,
resized_sample
;
size_
t
pos_count
=
0
;
in
t
pos_count
=
0
;
for
(
size_t
i
=
0
;
i
<
image_filenames
.
size
();
++
i
,
++
pos_count
)
{
Mat
img
=
imread
(
String
(
image_filenames
[
i
].
c_str
()));
...
...
@@ -92,7 +92,7 @@ void ICFDetector::train(const vector<string>& image_filenames,
for
(
size_t
i
=
0
;
i
<
image_filenames
.
size
();
++
i
)
{
Mat
img
=
imread
(
String
(
image_filenames
[
i
].
c_str
()));
for
(
size_
t
j
=
0
;
j
<
pos_count
/
image_filenames
.
size
()
+
1
;
)
for
(
in
t
j
=
0
;
j
<
pos_count
/
image_filenames
.
size
()
+
1
;
)
{
Rect
r
;
r
.
x
=
rng
.
uniform
(
0
,
img
.
cols
);
...
...
@@ -112,19 +112,19 @@ void ICFDetector::train(const vector<string>& image_filenames,
}
Mat_
<
int
>
labels
(
1
,
pos_count
+
neg_count
);
for
(
size_
t
i
=
0
;
i
<
pos_count
;
++
i
)
for
(
in
t
i
=
0
;
i
<
pos_count
;
++
i
)
labels
(
0
,
i
)
=
1
;
for
(
size_
t
i
=
pos_count
;
i
<
pos_count
+
neg_count
;
++
i
)
for
(
in
t
i
=
pos_count
;
i
<
pos_count
+
neg_count
;
++
i
)
labels
(
0
,
i
)
=
-
1
;
vector
<
Point3i
>
features
=
generateFeatures
(
model_size
);
ACFFeatureEvaluator
feature_evaluator
(
features
);
Mat_
<
int
>
data
(
features
.
size
(),
samples
.
size
());
Mat_
<
int
>
data
(
(
int
)
features
.
size
(),
(
int
)
samples
.
size
());
Mat_
<
int
>
feature_col
;
vector
<
Mat
>
channels
;
for
(
size_t
i
=
0
;
i
<
samples
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
(
int
)
samples
.
size
();
++
i
)
{
computeChannels
(
samples
[
i
],
channels
);
feature_evaluator
.
setChannels
(
channels
);
...
...
@@ -135,7 +135,7 @@ void ICFDetector::train(const vector<string>& image_filenames,
WaldBoostParams
wparams
;
wparams
.
weak_count
=
params
.
weak_count
;
wparams
.
alpha
=
0.001
;
wparams
.
alpha
=
0.001
f
;
WaldBoost
waldboost
(
wparams
);
waldboost
.
train
(
data
,
labels
);
...
...
modules/xobjdetect/src/stump.cpp
View file @
d8b0e8d5
...
...
@@ -81,7 +81,7 @@ int Stump::train(const Mat& data, const Mat& labels, const Mat& weights)
sorted_labels
.
at
<
int
>
(
row
,
col
)
=
labels
.
at
<
int
>
(
0
,
indices
.
at
<
int
>
(
row
,
col
));
sorted_weights
.
at
<
float
>
(
row
,
col
)
=
weights
.
at
<
float
>
(
0
,
indices
.
at
<
floa
t
>
(
row
,
col
));
weights
.
at
<
float
>
(
0
,
indices
.
at
<
in
t
>
(
row
,
col
));
}
}
...
...
@@ -124,7 +124,7 @@ int Stump::train(const Mat& data, const Mat& labels, const Mat& weights)
float
neg_total_weight
=
neg_cum_weights
.
at
<
float
>
(
0
,
weights
.
cols
-
1
);
float
eps
=
1.
/
4
*
labels
.
cols
;
float
eps
=
1.
0
f
/
4
*
labels
.
cols
;
/* Compute minimal error */
float
min_err
=
FLT_MAX
;
...
...
@@ -147,8 +147,8 @@ int Stump::train(const Mat& data, const Mat& labels, const Mat& weights)
float
neg_right
=
neg_cum_weights
.
at
<
float
>
(
row
,
col
);
float
neg_wrong
=
neg_total_weight
-
neg_right
;
h_pos
=
.5
*
log
((
pos_right
+
eps
)
/
(
pos_wrong
+
eps
));
h_neg
=
.5
*
log
((
neg_wrong
+
eps
)
/
(
neg_right
+
eps
));
h_pos
=
(
float
)(
.5
*
log
((
pos_right
+
eps
)
/
(
pos_wrong
+
eps
)
));
h_neg
=
(
float
)(
.5
*
log
((
neg_wrong
+
eps
)
/
(
neg_right
+
eps
)
));
err
=
sqrt
(
pos_right
*
neg_wrong
)
+
sqrt
(
pos_wrong
*
neg_right
);
...
...
modules/xobjdetect/src/waldboost.cpp
View file @
d8b0e8d5
...
...
@@ -69,8 +69,8 @@ vector<int> WaldBoost::train(const Mat& data, const Mat& labels)
}
Mat_
<
float
>
weights
(
labels
.
rows
,
labels
.
cols
);
float
pos_weight
=
1.
/
(
2
*
pos_count
);
float
neg_weight
=
1.
/
(
2
*
neg_count
);
float
pos_weight
=
1.
0
f
/
(
2
*
pos_count
);
float
neg_weight
=
1.
0
f
/
(
2
*
neg_count
);
for
(
int
col
=
0
;
col
<
weights
.
cols
;
++
col
)
{
if
(
labels
.
at
<
int
>
(
0
,
col
)
==
+
1
)
...
...
@@ -101,7 +101,7 @@ vector<int> WaldBoost::train(const Mat& data, const Mat& labels)
}
// Normalize weights
float
z
=
sum
(
weights
)[
0
];
float
z
=
(
float
)
sum
(
weights
)[
0
];
for
(
int
col
=
0
;
col
<
weights
.
cols
;
++
col
)
{
weights
.
at
<
float
>
(
0
,
col
)
/=
z
;
...
...
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