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
aa76ef9a
Commit
aa76ef9a
authored
May 07, 2014
by
Konstantin Matskevich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes
parent
36afd4ef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
27 deletions
+25
-27
contrib.hpp
modules/contrib/include/opencv2/contrib/contrib.hpp
+2
-2
facerec.cpp
modules/contrib/src/facerec.cpp
+22
-24
facerec_demo.cpp
samples/cpp/facerec_demo.cpp
+1
-1
No files found.
modules/contrib/include/opencv2/contrib/contrib.hpp
View file @
aa76ef9a
...
...
@@ -952,10 +952,10 @@ namespace cv
virtual
void
setLabelsInfo
(
const
std
::
map
<
int
,
string
>&
additionalInfo
)
=
0
;
// Gets string information by label
virtual
string
getLabelInfo
(
const
int
label
)
=
0
;
virtual
string
getLabelInfo
(
int
label
)
const
=
0
;
// Gets labels by string
virtual
vector
<
int
>
getLabelsByString
(
const
string
str
)
=
0
;
virtual
vector
<
int
>
getLabelsByString
(
const
string
&
str
)
=
0
;
};
CV_EXPORTS_W
Ptr
<
FaceRecognizer
>
createEigenFaceRecognizer
(
int
num_components
=
0
,
double
threshold
=
DBL_MAX
);
...
...
modules/contrib/src/facerec.cpp
View file @
aa76ef9a
...
...
@@ -21,9 +21,9 @@
struct
LabelInfo
{
LabelInfo
()
:
label
(
-
1
),
value
(
""
)
{}
LabelInfo
(
int
_label
,
std
::
string
_value
)
:
label
(
_label
),
value
(
_value
)
{}
std
::
string
value
;
LabelInfo
(
int
_label
,
const
std
::
string
&
_value
)
:
label
(
_label
),
value
(
_value
)
{}
int
label
;
std
::
string
value
;
void
write
(
cv
::
FileStorage
&
fs
)
const
{
fs
<<
"{"
<<
"label"
<<
label
<<
"value"
<<
value
<<
"}"
;
...
...
@@ -33,7 +33,11 @@ struct LabelInfo
label
=
(
int
)
node
[
"label"
];
value
=
(
std
::
string
)
node
[
"value"
];
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
LabelInfo
&
info
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
)
{
out
<<
"{ label = "
<<
label
<<
", "
<<
"value = "
<<
value
<<
"}"
;
return
out
;
}
};
static
void
write
(
cv
::
FileStorage
&
fs
,
const
std
::
string
&
,
const
LabelInfo
&
x
)
...
...
@@ -49,12 +53,6 @@ static void read(const cv::FileNode& node, LabelInfo& x, const LabelInfo& defaul
x
.
read
(
node
);
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
LabelInfo
&
info
)
{
out
<<
"{ label = "
<<
info
.
label
<<
", "
<<
"value = "
<<
info
.
value
<<
"}"
;
return
out
;
}
namespace
cv
{
...
...
@@ -188,10 +186,10 @@ public:
void
setLabelsInfo
(
const
std
::
map
<
int
,
string
>&
labelsInfo
);
// Gets additional information by label
string
getLabelInfo
(
const
int
label
)
;
string
getLabelInfo
(
int
label
)
const
;
// Gets labels by string
std
::
vector
<
int
>
getLabelsByString
(
const
string
str
);
std
::
vector
<
int
>
getLabelsByString
(
const
string
&
str
);
AlgorithmInfo
*
info
()
const
;
};
...
...
@@ -253,10 +251,10 @@ public:
void
setLabelsInfo
(
const
std
::
map
<
int
,
string
>&
labelsInfo
);
// Gets additional information by label
string
getLabelInfo
(
const
int
label
)
;
string
getLabelInfo
(
int
label
)
const
;
// Gets labels by string
std
::
vector
<
int
>
getLabelsByString
(
const
string
str
);
std
::
vector
<
int
>
getLabelsByString
(
const
string
&
str
);
AlgorithmInfo
*
info
()
const
;
};
...
...
@@ -348,10 +346,10 @@ public:
void
setLabelsInfo
(
const
std
::
map
<
int
,
string
>&
labelsInfo
);
// Gets additional information by label
string
getLabelInfo
(
const
int
label
)
;
string
getLabelInfo
(
int
label
)
const
;
// Gets labels by string
std
::
vector
<
int
>
getLabelsByString
(
const
string
str
);
std
::
vector
<
int
>
getLabelsByString
(
const
string
&
str
);
// Getter functions.
int
neighbors
()
const
{
return
_neighbors
;
}
...
...
@@ -522,14 +520,14 @@ void Eigenfaces::setLabelsInfo(const std::map<int,string>& labelsInfo)
_labelsInfo
=
labelsInfo
;
}
string
Eigenfaces
::
getLabelInfo
(
const
int
label
)
string
Eigenfaces
::
getLabelInfo
(
int
label
)
const
{
if
(
_labelsInfo
.
count
(
label
)
>
0
)
return
_labelsInfo
[
label
]
;
return
_labelsInfo
.
at
(
label
)
;
return
""
;
}
vector
<
int
>
Eigenfaces
::
getLabelsByString
(
const
string
str
)
vector
<
int
>
Eigenfaces
::
getLabelsByString
(
const
string
&
str
)
{
vector
<
int
>
labels
;
for
(
std
::
map
<
int
,
string
>::
const_iterator
it
=
_labelsInfo
.
begin
();
it
!=
_labelsInfo
.
end
();
it
++
)
...
...
@@ -683,14 +681,14 @@ void Fisherfaces::setLabelsInfo(const std::map<int,string>& labelsInfo)
_labelsInfo
=
labelsInfo
;
}
string
Fisherfaces
::
getLabelInfo
(
const
int
label
)
string
Fisherfaces
::
getLabelInfo
(
int
label
)
const
{
if
(
_labelsInfo
.
count
(
label
)
>
0
)
return
_labelsInfo
[
label
]
;
return
_labelsInfo
.
at
(
label
)
;
return
""
;
}
vector
<
int
>
Fisherfaces
::
getLabelsByString
(
const
string
str
)
vector
<
int
>
Fisherfaces
::
getLabelsByString
(
const
string
&
str
)
{
vector
<
int
>
labels
;
for
(
std
::
map
<
int
,
string
>::
const_iterator
it
=
_labelsInfo
.
begin
();
it
!=
_labelsInfo
.
end
();
it
++
)
...
...
@@ -920,14 +918,14 @@ void LBPH::setLabelsInfo(const std::map<int,string>& labelsInfo)
_labelsInfo
=
labelsInfo
;
}
string
LBPH
::
getLabelInfo
(
const
int
label
)
string
LBPH
::
getLabelInfo
(
int
label
)
const
{
if
(
_labelsInfo
.
count
(
label
)
>
0
)
return
_labelsInfo
[
label
]
;
return
_labelsInfo
.
at
(
label
)
;
return
""
;
}
vector
<
int
>
LBPH
::
getLabelsByString
(
const
string
str
)
vector
<
int
>
LBPH
::
getLabelsByString
(
const
string
&
str
)
{
vector
<
int
>
labels
;
for
(
std
::
map
<
int
,
string
>::
const_iterator
it
=
_labelsInfo
.
begin
();
it
!=
_labelsInfo
.
end
();
it
++
)
...
...
samples/cpp/facerec_demo.cpp
View file @
aa76ef9a
...
...
@@ -130,7 +130,7 @@ int main(int argc, const char *argv[]) {
//
string
result_message
=
format
(
"Predicted class = %d / Actual class = %d."
,
predictedLabel
,
testLabel
);
cout
<<
result_message
<<
endl
;
if
(
(
predictedLabel
==
testLabel
)
&&
(
model
->
getLabelInfo
(
predictedLabel
)
!=
""
)
)
if
(
(
predictedLabel
==
testLabel
)
&&
!
model
->
getLabelInfo
(
predictedLabel
).
empty
(
)
)
cout
<<
format
(
"%d-th label's info: %s"
,
predictedLabel
,
model
->
getLabelInfo
(
predictedLabel
).
c_str
())
<<
endl
;
// Sometimes you'll need to get/set internal model data,
// which isn't exposed by the public cv::FaceRecognizer.
...
...
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