Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Commits
b3c61ee0
Commit
b3c61ee0
authored
Jun 10, 2012
by
Philipp Wagner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor grammatical correction in comments.
parent
cd7d93f3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
facerec.cpp
modules/contrib/src/facerec.cpp
+8
-9
facerec_demo.cpp
samples/cpp/facerec_demo.cpp
+8
-7
No files found.
modules/contrib/src/facerec.cpp
View file @
b3c61ee0
...
...
@@ -53,7 +53,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double
// make sure the input data is a vector of matrices or vector of vector
if
(
src
.
kind
()
!=
_InputArray
::
STD_VECTOR_MAT
&&
src
.
kind
()
!=
_InputArray
::
STD_VECTOR_VECTOR
)
{
string
error_message
=
"The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< vector<...> >)."
;
error
(
Exception
(
CV_StsBadArg
,
error_message
,
"asRowMatrix"
,
__FILE__
,
__LINE__
)
);
CV_Error
(
CV_StsBadArg
,
error_message
);
}
// number of samples
size_t
n
=
src
.
total
();
...
...
@@ -69,7 +69,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double
// make sure data can be reshaped, throw exception if not!
if
(
src
.
getMat
(
i
).
total
()
!=
d
)
{
string
error_message
=
format
(
"Wrong number of elements in matrix #%d! Expected %d was %d."
,
i
,
d
,
src
.
getMat
(
i
).
total
());
error
(
Exception
(
CV_StsBadArg
,
error_message
,
"cv::asRowMatrix"
,
__FILE__
,
__LINE__
)
);
CV_Error
(
CV_StsBadArg
,
error_message
);
}
// get a hold of the current row
Mat
xi
=
data
.
row
(
i
);
...
...
@@ -125,8 +125,7 @@ public:
// corresponding labels in labels. num_components will be kept for
// classification.
Eigenfaces
(
InputArray
src
,
InputArray
labels
,
int
num_components
=
0
,
double
threshold
=
DBL_MAX
)
:
int
num_components
=
0
,
double
threshold
=
DBL_MAX
)
:
_num_components
(
num_components
),
_threshold
(
threshold
)
{
train
(
src
,
labels
);
...
...
@@ -178,10 +177,8 @@ public:
// Initializes and computes a Fisherfaces model with images in src and
// corresponding labels in labels. num_components will be kept for
// classification.
Fisherfaces
(
InputArray
src
,
InputArray
labels
,
int
num_components
=
0
,
double
threshold
=
DBL_MAX
)
:
Fisherfaces
(
InputArray
src
,
InputArray
labels
,
int
num_components
=
0
,
double
threshold
=
DBL_MAX
)
:
_num_components
(
num_components
),
_threshold
(
threshold
)
{
train
(
src
,
labels
);
...
...
@@ -235,7 +232,9 @@ public:
//
// radius, neighbors are used in the local binary patterns creation.
// grid_x, grid_y control the grid size of the spatial histograms.
LBPH
(
int
radius
=
1
,
int
neighbors
=
8
,
int
grid_x
=
8
,
int
grid_y
=
8
,
double
threshold
=
DBL_MAX
)
:
LBPH
(
int
radius
=
1
,
int
neighbors
=
8
,
int
grid_x
=
8
,
int
grid_y
=
8
,
double
threshold
=
DBL_MAX
)
:
_grid_x
(
grid_x
),
_grid_y
(
grid_y
),
_radius
(
radius
),
...
...
samples/cpp/facerec_demo.cpp
View file @
b3c61ee0
...
...
@@ -30,8 +30,9 @@ using namespace std;
static
Mat
toGrayscale
(
InputArray
_src
)
{
Mat
src
=
_src
.
getMat
();
// only allow one channel
if
(
src
.
channels
()
!=
1
)
if
(
src
.
channels
()
!=
1
)
{
CV_Error
(
CV_StsBadArg
,
"Only Matrices with one channel are supported"
);
}
// create and return normalized image
Mat
dst
;
cv
::
normalize
(
_src
,
dst
,
0
,
255
,
NORM_MINMAX
,
CV_8UC1
);
...
...
@@ -130,16 +131,16 @@ int main(int argc, const char *argv[]) {
// cv::Algorithm, you can query the data.
//
// First we'll use it to set the threshold of the FaceRecognizer
// without retraining the model:
// to 0.0 without retraining the model. This can be useful if
// you are evaluating the model:
//
model
->
set
(
"threshold"
,
0.0
);
// Now the threshold is of this model is 0.0. A prediction
// now returns -1, as it's impossible to have a distance
// below it
//
// Now the threshold of this model is set to 0.0. A prediction
// now returns -1, as it's impossible to have a distance below
// it
predictedLabel
=
model
->
predict
(
testSample
);
cout
<<
"Predicted class = "
<<
predictedLabel
<<
endl
;
//
Now h
ere is how to get the eigenvalues of this Eigenfaces model:
//
H
ere is how to get the eigenvalues of this Eigenfaces model:
Mat
eigenvalues
=
model
->
getMat
(
"eigenvalues"
);
// And we can do the same to display the Eigenvectors (read Eigenfaces):
Mat
W
=
model
->
getMat
(
"eigenvectors"
);
...
...
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