Commit 637e82dd authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #1251 from berak:face_cleanup

parents 8f23155d 8d9a3e43
......@@ -113,7 +113,7 @@ int num_components = 10;
double threshold = 10.0;
// Then if you want to have a cv::FaceRecognizer with a confidence threshold,
// create the concrete implementation with the appropiate parameters:
Ptr<FaceRecognizer> model = createEigenFaceRecognizer(num_components, threshold);
Ptr<FaceRecognizer> model = EigenFaceRecognizer::create(num_components, threshold);
@endcode
Sometimes it's impossible to train the model, just to experiment with threshold values. Thanks to
......@@ -148,7 +148,7 @@ FaceRecognizer:
@code
// Create a FaceRecognizer:
Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
Ptr<FaceRecognizer> model = EigenFaceRecognizer::create();
// And here's how to get its name:
String name = model->name();
@endcode
......@@ -192,7 +192,7 @@ public:
// Create a new Fisherfaces model and retain all available Fisherfaces,
// this is the most common usage of this specific FaceRecognizer:
//
Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
Ptr<FaceRecognizer> model = FisherFaceRecognizer::create();
@endcode
And finally train it on the given dataset (the face images and labels):
......@@ -223,7 +223,7 @@ public:
// Create a new LBPH model (it can be updated) and use the default parameters,
// 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
// implementations:
//
......@@ -241,7 +241,7 @@ public:
// with the new features extracted from newImages!
@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:
@code
......@@ -338,6 +338,9 @@ public:
/** @overload */
virtual void read(const FileNode& fn) = 0;
/** @overload */
virtual bool empty() const = 0;
/** @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.
......
......@@ -36,6 +36,7 @@ public:
virtual void read(const FileNode& fn);
virtual void write(FileStorage& fs) const;
virtual bool empty() const;
using FaceRecognizer::read;
using FaceRecognizer::write;
......@@ -72,8 +73,8 @@ public:
### Model internal data:
- num_components see createEigenFaceRecognizer.
- threshold see createEigenFaceRecognizer.
- num_components see EigenFaceRecognizer::create.
- threshold see EigenFaceRecognizer::create.
- eigenvalues The eigenvalues for this Principal Component Analysis (ordered descending).
- eigenvectors The eigenvectors for this Principal Component Analysis (ordered by their
eigenvalue).
......@@ -109,8 +110,8 @@ public:
### Model internal data:
- num_components see createFisherFaceRecognizer.
- threshold see createFisherFaceRecognizer.
- num_components see FisherFaceRecognizer::create.
- threshold see FisherFaceRecognizer::create.
- eigenvalues The eigenvalues for this Linear Discriminant Analysis (ordered descending).
- eigenvectors The eigenvectors for this Linear Discriminant Analysis (ordered by their
eigenvalue).
......@@ -171,11 +172,11 @@ public:
### Model internal data:
- radius see createLBPHFaceRecognizer.
- neighbors see createLBPHFaceRecognizer.
- grid_x see createLBPHFaceRecognizer.
- grid_y see createLBPHFaceRecognizer.
- threshold see createLBPHFaceRecognizer.
- radius see LBPHFaceRecognizer::create.
- neighbors see LBPHFaceRecognizer::create.
- grid_x see LLBPHFaceRecognizer::create.
- grid_y see LBPHFaceRecognizer::create.
- threshold see LBPHFaceRecognizer::create.
- histograms Local Binary Patterns Histograms calculated from the given training data (empty if
none was given).
- labels Labels corresponding to the calculated Local Binary Patterns Histograms.
......
......@@ -97,11 +97,11 @@ int main(int argc, const char *argv[]) {
// So if you want a LBPH FaceRecognizer using a radius of
// 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:
//
// cv::createLBPHFaceRecognizer(1,8,8,8,123.0)
// cv::face::LBPHFaceRecognizer::create(1,8,8,8,123.0)
//
Ptr<LBPHFaceRecognizer> model = LBPHFaceRecognizer::create();
model->train(images, labels);
......
......@@ -115,17 +115,17 @@ int main(int argc, const char *argv[]) {
// 10 principal components (read Eigenfaces), then call
// the factory method like this:
//
// cv::createEigenFaceRecognizer(10);
// cv::face::EigenFaceRecognizer::create(10);
//
// If you want to create a FaceRecognizer with a
// 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,
// then call the method like this:
//
// cv::createEigenFaceRecognizer(0, 123.0);
// cv::face::EigenFaceRecognizer::create(0, 123.0);
//
Ptr<EigenFaceRecognizer> model0 = EigenFaceRecognizer::create();
model0->train(images, labels);
......
......@@ -53,6 +53,7 @@ cv::Mat BasicFaceRecognizer::getMean() const
void BasicFaceRecognizer::read(const FileNode& fs)
{
//read matrices
fs["threshold"] >> _threshold;
fs["num_components"] >> _num_components;
fs["mean"] >> _mean;
fs["eigenvalues"] >> _eigenvalues;
......@@ -76,6 +77,7 @@ void BasicFaceRecognizer::read(const FileNode& fs)
void BasicFaceRecognizer::write(FileStorage& fs) const
{
// write matrices
fs << "threshold" << _threshold;
fs << "num_components" << _num_components;
fs << "mean" << _mean;
fs << "eigenvalues" << _eigenvalues;
......@@ -88,3 +90,8 @@ void BasicFaceRecognizer::write(FileStorage& fs) const
fs << LabelInfo(it->first, it->second);
fs << "]";
}
bool BasicFaceRecognizer::empty() const
{
return (_labels.empty());
}
......@@ -100,6 +100,10 @@ public:
// See FaceRecognizer::save.
void write(FileStorage& fs) const;
bool empty() const {
return (_labels.empty());
}
CV_IMPL_PROPERTY(int, GridX, _grid_x)
CV_IMPL_PROPERTY(int, GridY, _grid_y)
CV_IMPL_PROPERTY(int, Radius, _radius)
......@@ -111,6 +115,7 @@ public:
void LBPH::read(const FileNode& fs) {
fs["threshold"] >> _threshold;
fs["radius"] >> _radius;
fs["neighbors"] >> _neighbors;
fs["grid_x"] >> _grid_x;
......@@ -133,6 +138,7 @@ void LBPH::read(const FileNode& fs) {
// See FaceRecognizer::save.
void LBPH::write(FileStorage& fs) const {
fs << "threshold" << _threshold;
fs << "radius" << _radius;
fs << "neighbors" << _neighbors;
fs << "grid_x" << _grid_x;
......
......@@ -23,9 +23,9 @@ publications, because a lot of people asked for.
The currently available algorithms are:
- Eigenfaces (see createEigenFaceRecognizer)
- Fisherfaces (see createFisherFaceRecognizer)
- Local Binary Patterns Histograms (see createLBPHFaceRecognizer)
- Eigenfaces (see EigenFaceRecognizer::create)
- Fisherfaces (see FisherFaceRecognizer::create)
- 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
in the src folder coming with this documentation. If you have built OpenCV with the samples turned
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment