cv.BasicFaceRecognizer - MATLAB File Help Go to online doc for cv.BasicFaceRecognizer
cv.BasicFaceRecognizer

Face Recognition based on Eigen-/Fisher-faces

All face recognition models in OpenCV are derived from the abstract base class FaceRecognizer, which provides a unified access to all face recongition algorithms in OpenCV.

Description

Every FaceRecognizer supports the:

Setting the Thresholds

Sometimes you run into the situation, when you want to apply a threshold on the prediction. A common scenario in face recognition is to tell, whether a face belongs to the training dataset or if it is unknown. You can set the thresholds in the constructor. You can also get/set the thresholds at runtime!

Here is an example of setting a threshold for the Eigenfaces method, when creating the model:

% Let's say we want to keep 10 Eigenfaces and have a threshold value of 10.0
num_components = 10;
threshold = 10.0;
% Then if you want to have a face recognizer with a confidence threshold,
% create the concrete implementation with the appropiate parameters:
model = cv.BasicFaceRecognizer('Eigenfaces', ...
    'NumComponents',num_components, 'Threshold',threshold);

Sometimes it's impossible to train the model, just to experiment with threshold values. It's possible to set model thresholds during runtime. Let's see how we would set/get the prediction for the Eigenface model, we've created above:

% The following line reads the threshold from the Eigenfaces model:
current_threshold = model.Threshold;
% And this line sets the threshold to 0.0:
model.Threshold = 0.0;

If you've set the threshold to 0.0 as we did above, then:

img = cv.imread('person1/3.jpg', 'Grayscale',true);
% Get a prediction from the model. Note: We've set a threshold of 0.0 above,
% since the distance is almost always larger than 0.0, you'll get -1 as
% label, which indicates, this face is unknown
predicted_label = model.predict(img);
% ...

is going to yield -1 as predicted label, which states this face is unknown.

References

[TP91]:

Turk, M., and Pentland, A. "Eigenfaces for recognition". Journal of Cognitive Neuroscience 3 (1991), 71-86.

[BHK97]:

Belhumeur, P. N., Hespanha, J., and Kriegman, D. "Eigenfaces vs. Fisherfaces: Recognition using class specific linear projection". IEEE Transactions on Pattern Analysis and Machine Intelligence 19, 7 (1997), 711-720.

See also
Class Details
Superclasses handle
Sealed false
Construct on load false
Constructor Summary
BasicFaceRecognizer Constructor 
Property Summary
NumComponents The number of components kept by the PCA/LDA transformations. 
Threshold parameter, required for default BestMinDist collector. 
id Object ID 
Method Summary
  addlistener Add listener for event. 
  clear Clears the algorithm state 
  delete Destructor 
  empty Checks if detector object is empty 
  eq == (EQ) Test handle equality. 
  findobj Find objects matching specified conditions. 
  findprop Find property of MATLAB handle object. 
  ge >= (GE) Greater than or equal relation for handles. 
  getDefaultName Returns the algorithm string identifier 
  getEigenValues Get PCA/LDA eigenvalues 
  getEigenVectors Get PCA/LDA eigenvectors 
  getLabelInfo Gets string information by label 
  getLabels Get labels 
  getLabelsByString Gets vector of labels by string 
  getMean Get sample mean 
  getProjections Get training data projections 
  gt > (GT) Greater than relation for handles. 
Sealed   isvalid Test handle validity. 
  le <= (LE) Less than or equal relation for handles. 
  listener Add listener for event without binding the listener to the source object. 
  load Loads a FaceRecognizer and its model state 
  lt < (LT) Less than relation for handles. 
  ne ~= (NE) Not equal relation for handles. 
  notify Notify listeners of event. 
  predict Predicts a label and associated confidence (e.g. distance) for a given input image 
  predict_collect send all result of prediction to collector for custom result handling 
  save Saves a FaceRecognizer and its model state 
  setLabelInfo Sets string info for the specified model's label 
  train Trains a FaceRecognizer with given data and associated labels 
  typeid Name of the C++ type (RTTI) 
  update Updates a FaceRecognizer with given data and associated labels 
Event Summary
ObjectBeingDestroyed Notifies listeners that a particular object has been destroyed.