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
85aaf88a
Commit
85aaf88a
authored
Jul 03, 2014
by
Vlad Shakhuro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Derive ACFFeatureEvaluator from Algorithm
parent
c994b489
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
37 deletions
+60
-37
xobjdetect.hpp
modules/xobjdetect/include/opencv2/xobjdetect.hpp
+10
-16
acffeature.cpp
modules/xobjdetect/src/acffeature.cpp
+47
-18
icfdetector.cpp
modules/xobjdetect/src/icfdetector.cpp
+3
-3
No files found.
modules/xobjdetect/include/opencv2/xobjdetect.hpp
View file @
85aaf88a
...
...
@@ -60,37 +60,31 @@ namespace xobjdetect
*/
void
computeChannels
(
InputArray
image
,
OutputArrayOfArrays
channels
);
class
CV_EXPORTS
ACFFeatureEvaluator
class
CV_EXPORTS
ACFFeatureEvaluator
:
public
Algorithm
{
public
:
/* Construct evaluator, set features to evaluate */
ACFFeatureEvaluator
(
const
std
::
vector
<
Point3i
>&
features
);
/* Set channels for feature evaluation */
v
oid
setChannels
(
InputArrayOfArrays
channels
)
;
v
irtual
void
setChannels
(
InputArrayOfArrays
channels
)
=
0
;
/* Set window position */
v
oid
setPosition
(
Size
position
)
;
v
irtual
void
setPosition
(
Size
position
)
=
0
;
/* Evaluate feature with given index for current channels
and window position */
int
evaluate
(
size_t
feature_ind
)
const
;
virtual
int
evaluate
(
size_t
feature_ind
)
const
=
0
;
/* Evaluate all features for current channels and window position
Returns matrix-column of features
*/
v
oid
evaluateAll
(
OutputArray
feature_values
)
const
;
v
irtual
void
evaluateAll
(
OutputArray
feature_values
)
const
=
0
;
private
:
/* Features to evaluate */
std
::
vector
<
Point3i
>
features_
;
/* Channels for feature evaluation */
std
::
vector
<
Mat
>
channels_
;
/* Channels window position */
Size
position_
;
};
/* Construct evaluator, set features to evaluate */
CV_EXPORTS
Ptr
<
ACFFeatureEvaluator
>
createACFFeatureEvaluator
(
const
std
::
vector
<
Point3i
>&
features
);
/* Generate acf features
window_size — size of window in which features should be evaluated
...
...
@@ -158,7 +152,7 @@ private:
float
pos_value_
,
neg_value_
;
};
class
CV_EXPORTS
WaldBoost
class
CV_EXPORTS
WaldBoost
:
public
Algorithm
{
public
:
/* Initialize WaldBoost cascade with default of specified parameters */
...
...
modules/xobjdetect/src/acffeature.cpp
View file @
85aaf88a
...
...
@@ -45,33 +45,44 @@ using std::vector;
using
std
::
min
;
#include <iostream>
using
std
::
cout
;
using
std
::
endl
;
namespace
cv
{
namespace
xobjdetect
{
ACFFeatureEvaluator
::
ACFFeatureEvaluator
(
const
vector
<
Point3i
>&
features
)
:
features_
(
features
),
channels_
(),
position_
()
{
}
int
ACFFeatureEvaluator
::
evaluate
(
size_t
feature_ind
)
const
class
ACFFeatureEvaluatorImpl
:
public
ACFFeatureEvaluator
{
/* Assume there are 10 channels */
CV_Assert
(
channels_
.
size
()
==
10
);
CV_Assert
(
feature_ind
<
features_
.
size
());
Point3i
feature
=
features_
.
at
(
feature_ind
);
int
x
=
feature
.
x
;
int
y
=
feature
.
y
;
int
n
=
feature
.
z
;
return
channels_
[
n
].
at
<
int
>
(
y
,
x
);
}
public
:
ACFFeatureEvaluatorImpl
(
const
vector
<
Point3i
>&
features
)
:
features_
(
features
),
channels_
(),
position_
()
{
CV_Assert
(
features
.
size
()
>
0
);
}
void
ACFFeatureEvaluator
::
setChannels
(
cv
::
InputArrayOfArrays
channels
)
virtual
void
setChannels
(
InputArrayOfArrays
channels
);
virtual
void
setPosition
(
Size
position
);
virtual
int
evaluate
(
size_t
feature_ind
)
const
;
virtual
void
evaluateAll
(
OutputArray
feature_values
)
const
;
private
:
/* Features to evaluate */
std
::
vector
<
Point3i
>
features_
;
/* Channels for feature evaluation */
std
::
vector
<
Mat
>
channels_
;
/* Channels window position */
Size
position_
;
};
void
ACFFeatureEvaluatorImpl
::
setChannels
(
cv
::
InputArrayOfArrays
channels
)
{
channels_
.
clear
();
vector
<
Mat
>
ch
;
channels
.
getMatVector
(
ch
);
CV_Assert
(
ch
.
size
()
==
10
);
for
(
size_t
i
=
0
;
i
<
ch
.
size
();
++
i
)
{
const
Mat
&
channel
=
ch
[
i
];
...
...
@@ -92,12 +103,24 @@ void ACFFeatureEvaluator::setChannels(cv::InputArrayOfArrays channels)
}
}
void
ACFFeatureEvaluator
::
setPosition
(
Size
position
)
void
ACFFeatureEvaluator
Impl
::
setPosition
(
Size
position
)
{
position_
=
position
;
}
void
ACFFeatureEvaluator
::
evaluateAll
(
OutputArray
feature_values
)
const
int
ACFFeatureEvaluatorImpl
::
evaluate
(
size_t
feature_ind
)
const
{
CV_Assert
(
channels_
.
size
()
==
10
);
CV_Assert
(
feature_ind
<
features_
.
size
());
Point3i
feature
=
features_
.
at
(
feature_ind
);
int
x
=
feature
.
x
;
int
y
=
feature
.
y
;
int
n
=
feature
.
z
;
return
channels_
[
n
].
at
<
int
>
(
y
,
x
);
}
void
ACFFeatureEvaluatorImpl
::
evaluateAll
(
OutputArray
feature_values
)
const
{
Mat_
<
int
>
feature_vals
(
1
,
(
int
)
features_
.
size
());
for
(
int
i
=
0
;
i
<
(
int
)
features_
.
size
();
++
i
)
...
...
@@ -107,6 +130,12 @@ void ACFFeatureEvaluator::evaluateAll(OutputArray feature_values) const
feature_values
.
setTo
(
feature_vals
);
}
Ptr
<
ACFFeatureEvaluator
>
createACFFeatureEvaluator
(
const
vector
<
Point3i
>&
features
)
{
return
Ptr
<
ACFFeatureEvaluator
>
(
new
ACFFeatureEvaluatorImpl
(
features
));
}
vector
<
Point3i
>
generateFeatures
(
Size
window_size
,
int
count
)
{
CV_Assert
(
count
>
0
);
...
...
modules/xobjdetect/src/icfdetector.cpp
View file @
85aaf88a
...
...
@@ -118,7 +118,7 @@ void ICFDetector::train(const vector<string>& image_filenames,
labels
(
0
,
i
)
=
-
1
;
vector
<
Point3i
>
features
=
generateFeatures
(
model_size
);
ACFFeatureEvaluator
feature_e
valuator
(
features
);
Ptr
<
ACFFeatureEvaluator
>
feature_evaluator
=
createACFFeatureE
valuator
(
features
);
Mat_
<
int
>
data
((
int
)
features
.
size
(),
(
int
)
samples
.
size
());
Mat_
<
int
>
feature_col
;
...
...
@@ -127,8 +127,8 @@ void ICFDetector::train(const vector<string>& image_filenames,
for
(
int
i
=
0
;
i
<
(
int
)
samples
.
size
();
++
i
)
{
computeChannels
(
samples
[
i
],
channels
);
feature_evaluator
.
setChannels
(
channels
);
feature_evaluator
.
evaluateAll
(
feature_col
);
feature_evaluator
->
setChannels
(
channels
);
feature_evaluator
->
evaluateAll
(
feature_col
);
for
(
int
j
=
0
;
j
<
feature_col
.
rows
;
++
j
)
data
(
i
,
j
)
=
feature_col
(
0
,
j
);
}
...
...
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