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
8d9a3e43
Commit
8d9a3e43
authored
Jun 24, 2017
by
berak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
face: minor cleanup after #1239
parent
8f23155d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
22 deletions
+39
-22
face.hpp
modules/face/include/opencv2/face.hpp
+8
-5
facerec.hpp
modules/face/include/opencv2/face/facerec.hpp
+10
-9
facerec_lbph.cpp
modules/face/samples/facerec_lbph.cpp
+2
-2
facerec_save_load.cpp
modules/face/samples/facerec_save_load.cpp
+3
-3
face_basic.cpp
modules/face/src/face_basic.cpp
+7
-0
lbph_faces.cpp
modules/face/src/lbph_faces.cpp
+6
-0
face_tutorial.markdown
modules/face/tutorials/face_tutorial.markdown
+3
-3
No files found.
modules/face/include/opencv2/face.hpp
View file @
8d9a3e43
...
@@ -113,7 +113,7 @@ int num_components = 10;
...
@@ -113,7 +113,7 @@ int num_components = 10;
double threshold = 10.0;
double threshold = 10.0;
// Then if you want to have a cv::FaceRecognizer with a confidence threshold,
// Then if you want to have a cv::FaceRecognizer with a confidence threshold,
// create the concrete implementation with the appropiate parameters:
// create the concrete implementation with the appropiate parameters:
Ptr<FaceRecognizer> model =
createEigenFaceRecognizer
(num_components, threshold);
Ptr<FaceRecognizer> model =
EigenFaceRecognizer::create
(num_components, threshold);
@endcode
@endcode
Sometimes it's impossible to train the model, just to experiment with threshold values. Thanks to
Sometimes it's impossible to train the model, just to experiment with threshold values. Thanks to
...
@@ -148,7 +148,7 @@ FaceRecognizer:
...
@@ -148,7 +148,7 @@ FaceRecognizer:
@code
@code
// Create a FaceRecognizer:
// Create a FaceRecognizer:
Ptr<FaceRecognizer> model =
createEigenFaceRecognizer
();
Ptr<FaceRecognizer> model =
EigenFaceRecognizer::create
();
// And here's how to get its name:
// And here's how to get its name:
String name = model->name();
String name = model->name();
@endcode
@endcode
...
@@ -192,7 +192,7 @@ public:
...
@@ -192,7 +192,7 @@ public:
// Create a new Fisherfaces model and retain all available Fisherfaces,
// Create a new Fisherfaces model and retain all available Fisherfaces,
// this is the most common usage of this specific FaceRecognizer:
// this is the most common usage of this specific FaceRecognizer:
//
//
Ptr<FaceRecognizer> model =
createFisherFaceRecognizer
();
Ptr<FaceRecognizer> model =
FisherFaceRecognizer::create
();
@endcode
@endcode
And finally train it on the given dataset (the face images and labels):
And finally train it on the given dataset (the face images and labels):
...
@@ -223,7 +223,7 @@ public:
...
@@ -223,7 +223,7 @@ public:
// Create a new LBPH model (it can be updated) and use the default parameters,
// Create a new LBPH model (it can be updated) and use the default parameters,
// this is the most common usage of this specific FaceRecognizer:
// this is the most common usage of this specific FaceRecognizer:
//
//
Ptr<FaceRecognizer> model =
createLBPHFaceRecognizer
();
Ptr<FaceRecognizer> model =
LBPHFaceRecognizer::create
();
// This is the common interface to train all of the available cv::FaceRecognizer
// This is the common interface to train all of the available cv::FaceRecognizer
// implementations:
// implementations:
//
//
...
@@ -241,7 +241,7 @@ public:
...
@@ -241,7 +241,7 @@ public:
// with the new features extracted from newImages!
// with the new features extracted from newImages!
@endcode
@endcode
Calling update on an Eigenfaces model (see
createEigenFaceRecognizer
), which doesn't support
Calling update on an Eigenfaces model (see
EigenFaceRecognizer::create
), which doesn't support
updating, will throw an error similar to:
updating, will throw an error similar to:
@code
@code
...
@@ -338,6 +338,9 @@ public:
...
@@ -338,6 +338,9 @@ public:
/** @overload */
/** @overload */
virtual
void
read
(
const
FileNode
&
fn
)
=
0
;
virtual
void
read
(
const
FileNode
&
fn
)
=
0
;
/** @overload */
virtual
bool
empty
()
const
=
0
;
/** @brief Sets string info for the specified model's label.
/** @brief Sets string info for the specified model's label.
The string info is replaced by the provided value if it was set before for the specified label.
The string info is replaced by the provided value if it was set before for the specified label.
...
...
modules/face/include/opencv2/face/facerec.hpp
View file @
8d9a3e43
...
@@ -36,6 +36,7 @@ public:
...
@@ -36,6 +36,7 @@ public:
virtual
void
read
(
const
FileNode
&
fn
);
virtual
void
read
(
const
FileNode
&
fn
);
virtual
void
write
(
FileStorage
&
fs
)
const
;
virtual
void
write
(
FileStorage
&
fs
)
const
;
virtual
bool
empty
()
const
;
using
FaceRecognizer
::
read
;
using
FaceRecognizer
::
read
;
using
FaceRecognizer
::
write
;
using
FaceRecognizer
::
write
;
...
@@ -72,8 +73,8 @@ public:
...
@@ -72,8 +73,8 @@ public:
### Model internal data:
### Model internal data:
- num_components see
createEigenFaceRecognizer
.
- num_components see
EigenFaceRecognizer::create
.
- threshold see
createEigenFaceRecognizer
.
- threshold see
EigenFaceRecognizer::create
.
- eigenvalues The eigenvalues for this Principal Component Analysis (ordered descending).
- eigenvalues The eigenvalues for this Principal Component Analysis (ordered descending).
- eigenvectors The eigenvectors for this Principal Component Analysis (ordered by their
- eigenvectors The eigenvectors for this Principal Component Analysis (ordered by their
eigenvalue).
eigenvalue).
...
@@ -109,8 +110,8 @@ public:
...
@@ -109,8 +110,8 @@ public:
### Model internal data:
### Model internal data:
- num_components see
createFisherFaceRecognizer
.
- num_components see
FisherFaceRecognizer::create
.
- threshold see
createFisherFaceRecognizer
.
- threshold see
FisherFaceRecognizer::create
.
- eigenvalues The eigenvalues for this Linear Discriminant Analysis (ordered descending).
- eigenvalues The eigenvalues for this Linear Discriminant Analysis (ordered descending).
- eigenvectors The eigenvectors for this Linear Discriminant Analysis (ordered by their
- eigenvectors The eigenvectors for this Linear Discriminant Analysis (ordered by their
eigenvalue).
eigenvalue).
...
@@ -171,11 +172,11 @@ public:
...
@@ -171,11 +172,11 @@ public:
### Model internal data:
### Model internal data:
- radius see
createLBPHFaceRecognizer
.
- radius see
LBPHFaceRecognizer::create
.
- neighbors see
createLBPHFaceRecognizer
.
- neighbors see
LBPHFaceRecognizer::create
.
- grid_x see
createLBPHFaceRecognizer
.
- grid_x see
LLBPHFaceRecognizer::create
.
- grid_y see
createLBPHFaceRecognizer
.
- grid_y see
LBPHFaceRecognizer::create
.
- threshold see
createLBPHFaceRecognizer
.
- threshold see
LBPHFaceRecognizer::create
.
- histograms Local Binary Patterns Histograms calculated from the given training data (empty if
- histograms Local Binary Patterns Histograms calculated from the given training data (empty if
none was given).
none was given).
- labels Labels corresponding to the calculated Local Binary Patterns Histograms.
- labels Labels corresponding to the calculated Local Binary Patterns Histograms.
...
...
modules/face/samples/facerec_lbph.cpp
View file @
8d9a3e43
...
@@ -97,11 +97,11 @@ int main(int argc, const char *argv[]) {
...
@@ -97,11 +97,11 @@ int main(int argc, const char *argv[]) {
// So if you want a LBPH FaceRecognizer using a radius of
// So if you want a LBPH FaceRecognizer using a radius of
// 2 and 16 neighbors, call the factory method with:
// 2 and 16 neighbors, call the factory method with:
//
//
// cv::
createLBPHFaceRecognizer
(2, 16);
// cv::
face::LBPHFaceRecognizer::create
(2, 16);
//
//
// And if you want a threshold (e.g. 123.0) call it with its default values:
// And if you want a threshold (e.g. 123.0) call it with its default values:
//
//
// cv::
createLBPHFaceRecognizer
(1,8,8,8,123.0)
// cv::
face::LBPHFaceRecognizer::create
(1,8,8,8,123.0)
//
//
Ptr
<
LBPHFaceRecognizer
>
model
=
LBPHFaceRecognizer
::
create
();
Ptr
<
LBPHFaceRecognizer
>
model
=
LBPHFaceRecognizer
::
create
();
model
->
train
(
images
,
labels
);
model
->
train
(
images
,
labels
);
...
...
modules/face/samples/facerec_save_load.cpp
View file @
8d9a3e43
...
@@ -115,17 +115,17 @@ int main(int argc, const char *argv[]) {
...
@@ -115,17 +115,17 @@ int main(int argc, const char *argv[]) {
// 10 principal components (read Eigenfaces), then call
// 10 principal components (read Eigenfaces), then call
// the factory method like this:
// the factory method like this:
//
//
// cv::
createEigenFaceRecognizer
(10);
// cv::
face::EigenFaceRecognizer::create
(10);
//
//
// If you want to create a FaceRecognizer with a
// If you want to create a FaceRecognizer with a
// confidence threshold (e.g. 123.0), call it with:
// confidence threshold (e.g. 123.0), call it with:
//
//
// cv::
createEigenFaceRecognizer
(10, 123.0);
// cv::
face::EigenFaceRecognizer::create
(10, 123.0);
//
//
// If you want to use _all_ Eigenfaces and have a threshold,
// If you want to use _all_ Eigenfaces and have a threshold,
// then call the method like this:
// then call the method like this:
//
//
// cv::
createEigenFaceRecognizer
(0, 123.0);
// cv::
face::EigenFaceRecognizer::create
(0, 123.0);
//
//
Ptr
<
EigenFaceRecognizer
>
model0
=
EigenFaceRecognizer
::
create
();
Ptr
<
EigenFaceRecognizer
>
model0
=
EigenFaceRecognizer
::
create
();
model0
->
train
(
images
,
labels
);
model0
->
train
(
images
,
labels
);
...
...
modules/face/src/face_basic.cpp
View file @
8d9a3e43
...
@@ -53,6 +53,7 @@ cv::Mat BasicFaceRecognizer::getMean() const
...
@@ -53,6 +53,7 @@ cv::Mat BasicFaceRecognizer::getMean() const
void
BasicFaceRecognizer
::
read
(
const
FileNode
&
fs
)
void
BasicFaceRecognizer
::
read
(
const
FileNode
&
fs
)
{
{
//read matrices
//read matrices
fs
[
"threshold"
]
>>
_threshold
;
fs
[
"num_components"
]
>>
_num_components
;
fs
[
"num_components"
]
>>
_num_components
;
fs
[
"mean"
]
>>
_mean
;
fs
[
"mean"
]
>>
_mean
;
fs
[
"eigenvalues"
]
>>
_eigenvalues
;
fs
[
"eigenvalues"
]
>>
_eigenvalues
;
...
@@ -76,6 +77,7 @@ void BasicFaceRecognizer::read(const FileNode& fs)
...
@@ -76,6 +77,7 @@ void BasicFaceRecognizer::read(const FileNode& fs)
void
BasicFaceRecognizer
::
write
(
FileStorage
&
fs
)
const
void
BasicFaceRecognizer
::
write
(
FileStorage
&
fs
)
const
{
{
// write matrices
// write matrices
fs
<<
"threshold"
<<
_threshold
;
fs
<<
"num_components"
<<
_num_components
;
fs
<<
"num_components"
<<
_num_components
;
fs
<<
"mean"
<<
_mean
;
fs
<<
"mean"
<<
_mean
;
fs
<<
"eigenvalues"
<<
_eigenvalues
;
fs
<<
"eigenvalues"
<<
_eigenvalues
;
...
@@ -88,3 +90,8 @@ void BasicFaceRecognizer::write(FileStorage& fs) const
...
@@ -88,3 +90,8 @@ void BasicFaceRecognizer::write(FileStorage& fs) const
fs
<<
LabelInfo
(
it
->
first
,
it
->
second
);
fs
<<
LabelInfo
(
it
->
first
,
it
->
second
);
fs
<<
"]"
;
fs
<<
"]"
;
}
}
bool
BasicFaceRecognizer
::
empty
()
const
{
return
(
_labels
.
empty
());
}
modules/face/src/lbph_faces.cpp
View file @
8d9a3e43
...
@@ -100,6 +100,10 @@ public:
...
@@ -100,6 +100,10 @@ public:
// See FaceRecognizer::save.
// See FaceRecognizer::save.
void
write
(
FileStorage
&
fs
)
const
;
void
write
(
FileStorage
&
fs
)
const
;
bool
empty
()
const
{
return
(
_labels
.
empty
());
}
CV_IMPL_PROPERTY
(
int
,
GridX
,
_grid_x
)
CV_IMPL_PROPERTY
(
int
,
GridX
,
_grid_x
)
CV_IMPL_PROPERTY
(
int
,
GridY
,
_grid_y
)
CV_IMPL_PROPERTY
(
int
,
GridY
,
_grid_y
)
CV_IMPL_PROPERTY
(
int
,
Radius
,
_radius
)
CV_IMPL_PROPERTY
(
int
,
Radius
,
_radius
)
...
@@ -111,6 +115,7 @@ public:
...
@@ -111,6 +115,7 @@ public:
void
LBPH
::
read
(
const
FileNode
&
fs
)
{
void
LBPH
::
read
(
const
FileNode
&
fs
)
{
fs
[
"threshold"
]
>>
_threshold
;
fs
[
"radius"
]
>>
_radius
;
fs
[
"radius"
]
>>
_radius
;
fs
[
"neighbors"
]
>>
_neighbors
;
fs
[
"neighbors"
]
>>
_neighbors
;
fs
[
"grid_x"
]
>>
_grid_x
;
fs
[
"grid_x"
]
>>
_grid_x
;
...
@@ -133,6 +138,7 @@ void LBPH::read(const FileNode& fs) {
...
@@ -133,6 +138,7 @@ void LBPH::read(const FileNode& fs) {
// See FaceRecognizer::save.
// See FaceRecognizer::save.
void
LBPH
::
write
(
FileStorage
&
fs
)
const
{
void
LBPH
::
write
(
FileStorage
&
fs
)
const
{
fs
<<
"threshold"
<<
_threshold
;
fs
<<
"radius"
<<
_radius
;
fs
<<
"radius"
<<
_radius
;
fs
<<
"neighbors"
<<
_neighbors
;
fs
<<
"neighbors"
<<
_neighbors
;
fs
<<
"grid_x"
<<
_grid_x
;
fs
<<
"grid_x"
<<
_grid_x
;
...
...
modules/face/tutorials/face_tutorial.markdown
View file @
8d9a3e43
...
@@ -23,9 +23,9 @@ publications, because a lot of people asked for.
...
@@ -23,9 +23,9 @@ publications, because a lot of people asked for.
The currently available algorithms are:
The currently available algorithms are:
-
Eigenfaces (see
createEigenFaceRecognizer
)
-
Eigenfaces (see
EigenFaceRecognizer::create
)
-
Fisherfaces (see
createFisherFaceRecognizer
)
-
Fisherfaces (see
FisherFaceRecognizer::create
)
-
Local Binary Patterns Histograms (see
createLBPHFaceRecognizer
)
-
Local Binary Patterns Histograms (see
LBPHFaceRecognizer::create
)
You don't need to copy and paste the source code examples from this page, because they are available
You don't need to copy and paste the source code examples from this page, because they are available
in the src folder coming with this documentation. If you have built OpenCV with the samples turned
in the src folder coming with this documentation. If you have built OpenCV with the samples turned
...
...
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