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
02b32d86
Commit
02b32d86
authored
Jun 09, 2014
by
Andrey Pavlenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moving FaceRecognizer2 from public header to .cpp
parent
59c8edfd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
70 deletions
+67
-70
contrib.hpp
modules/contrib/include/opencv2/contrib/contrib.hpp
+0
-20
facerec.cpp
modules/contrib/src/facerec.cpp
+67
-50
No files found.
modules/contrib/include/opencv2/contrib/contrib.hpp
View file @
02b32d86
...
@@ -958,26 +958,6 @@ namespace cv
...
@@ -958,26 +958,6 @@ namespace cv
vector
<
int
>
getLabelsByString
(
const
string
&
str
);
vector
<
int
>
getLabelsByString
(
const
string
&
str
);
};
};
// The FaceRecognizerBase class is introduced to keep the FaceRecognizer binary backward compatibility in 2.4
// In master setLabelInfo/getLabelInfo/getLabelsByString should be virtual and _labelsInfo should be moved to FaceRecognizer
// that allows to avoid FaceRecognizer2 in master
class
FaceRecognizer2
:
public
FaceRecognizer
{
protected
:
// Stored pairs "label id - string info"
std
::
map
<
int
,
string
>
_labelsInfo
;
public
:
// Sets additional information as pairs label - info.
virtual
void
setLabelsInfo
(
const
std
::
map
<
int
,
string
>&
labelsInfo
);
// Gets string information by label
virtual
string
getLabelInfo
(
int
label
)
const
;
// Gets labels by string
virtual
vector
<
int
>
getLabelsByString
(
const
string
&
str
);
};
CV_EXPORTS_W
Ptr
<
FaceRecognizer
>
createEigenFaceRecognizer
(
int
num_components
=
0
,
double
threshold
=
DBL_MAX
);
CV_EXPORTS_W
Ptr
<
FaceRecognizer
>
createEigenFaceRecognizer
(
int
num_components
=
0
,
double
threshold
=
DBL_MAX
);
CV_EXPORTS_W
Ptr
<
FaceRecognizer
>
createFisherFaceRecognizer
(
int
num_components
=
0
,
double
threshold
=
DBL_MAX
);
CV_EXPORTS_W
Ptr
<
FaceRecognizer
>
createFisherFaceRecognizer
(
int
num_components
=
0
,
double
threshold
=
DBL_MAX
);
CV_EXPORTS_W
Ptr
<
FaceRecognizer
>
createLBPHFaceRecognizer
(
int
radius
=
1
,
int
neighbors
=
8
,
CV_EXPORTS_W
Ptr
<
FaceRecognizer
>
createLBPHFaceRecognizer
(
int
radius
=
1
,
int
neighbors
=
8
,
...
...
modules/contrib/src/facerec.cpp
View file @
02b32d86
...
@@ -18,41 +18,6 @@
...
@@ -18,41 +18,6 @@
#include "precomp.hpp"
#include "precomp.hpp"
#include <set>
#include <set>
struct
LabelInfo
{
LabelInfo
()
:
label
(
-
1
),
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
<<
"}"
;
}
void
read
(
const
cv
::
FileNode
&
node
)
{
label
=
(
int
)
node
[
"label"
];
value
=
(
std
::
string
)
node
[
"value"
];
}
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
)
{
x
.
write
(
fs
);
}
static
void
read
(
const
cv
::
FileNode
&
node
,
LabelInfo
&
x
,
const
LabelInfo
&
default_value
=
LabelInfo
())
{
if
(
node
.
empty
())
x
=
default_value
;
else
x
.
read
(
node
);
}
namespace
cv
namespace
cv
{
{
...
@@ -133,29 +98,81 @@ inline vector<_Tp> remove_dups(const vector<_Tp>& src) {
...
@@ -133,29 +98,81 @@ inline vector<_Tp> remove_dups(const vector<_Tp>& src) {
return
elems
;
return
elems
;
}
}
void
FaceRecognizer2
::
setLabelsInfo
(
const
std
::
map
<
int
,
string
>&
labelsInfo
)
// The FaceRecognizer2 class is introduced to keep the FaceRecognizer binary backward compatibility in 2.4
// In master setLabelInfo/getLabelInfo/getLabelsByString should be virtual and _labelsInfo should be moved
// to FaceRecognizer, that allows to avoid FaceRecognizer2 in master
class
FaceRecognizer2
:
public
FaceRecognizer
{
{
_labelsInfo
=
labelsInfo
;
protected
:
}
// Stored pairs "label id - string info"
std
::
map
<
int
,
string
>
_labelsInfo
;
string
FaceRecognizer2
::
getLabelInfo
(
int
label
)
const
public
:
{
// Sets additional information as pairs label - info.
std
::
map
<
int
,
string
>::
const_iterator
iter
(
_labelsInfo
.
find
(
label
));
virtual
void
setLabelsInfo
(
const
std
::
map
<
int
,
string
>&
labelsInfo
)
return
iter
!=
_labelsInfo
.
end
()
?
iter
->
second
:
""
;
{
}
_labelsInfo
=
labelsInfo
;
}
vector
<
int
>
FaceRecognizer2
::
getLabelsByString
(
const
string
&
str
)
// Gets string information by label
virtual
string
getLabelInfo
(
int
label
)
const
{
std
::
map
<
int
,
string
>::
const_iterator
iter
(
_labelsInfo
.
find
(
label
));
return
iter
!=
_labelsInfo
.
end
()
?
iter
->
second
:
""
;
}
// Gets labels by string
virtual
vector
<
int
>
getLabelsByString
(
const
string
&
str
)
{
vector
<
int
>
labels
;
for
(
std
::
map
<
int
,
string
>::
const_iterator
it
=
_labelsInfo
.
begin
();
it
!=
_labelsInfo
.
end
();
it
++
)
{
size_t
found
=
(
it
->
second
).
find
(
str
);
if
(
found
!=
string
::
npos
)
labels
.
push_back
(
it
->
first
);
}
return
labels
;
}
};
// Utility structure to load/save face label info (a pair of int and string) via FileStorage
struct
LabelInfo
{
{
vector
<
int
>
labels
;
LabelInfo
()
:
label
(
-
1
),
value
(
""
)
{}
for
(
std
::
map
<
int
,
string
>::
const_iterator
it
=
_labelsInfo
.
begin
();
it
!=
_labelsInfo
.
end
();
it
++
)
LabelInfo
(
int
_label
,
const
std
::
string
&
_value
)
:
label
(
_label
),
value
(
_value
)
{}
int
label
;
std
::
string
value
;
void
write
(
cv
::
FileStorage
&
fs
)
const
{
{
size_t
found
=
(
it
->
second
).
find
(
str
);
fs
<<
"{"
<<
"label"
<<
label
<<
"value"
<<
value
<<
"}"
;
if
(
found
!=
string
::
npos
)
labels
.
push_back
(
it
->
first
);
}
}
return
labels
;
void
read
(
const
cv
::
FileNode
&
node
)
{
label
=
(
int
)
node
[
"label"
];
value
=
(
std
::
string
)
node
[
"value"
];
}
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
)
{
x
.
write
(
fs
);
}
static
void
read
(
const
cv
::
FileNode
&
node
,
LabelInfo
&
x
,
const
LabelInfo
&
default_value
=
LabelInfo
())
{
if
(
node
.
empty
())
x
=
default_value
;
else
x
.
read
(
node
);
}
}
// Turk, M., and Pentland, A. "Eigenfaces for recognition.". Journal of
// Turk, M., and Pentland, A. "Eigenfaces for recognition.". Journal of
// Cognitive Neuroscience 3 (1991), 71–86.
// Cognitive Neuroscience 3 (1991), 71–86.
class
Eigenfaces
:
public
FaceRecognizer2
class
Eigenfaces
:
public
FaceRecognizer2
...
...
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