|
visageSDK
|
VisageFaceRecognition class contains a face recognition algorithm capable of measuring similarity between human faces and recognizing a person's identity from frontal facial images (yaw angle approximately from -20 to 20 degrees). More...
Public Member Functions | |
| VisageFaceRecognition (System::String^dataPath) | |
| Constructor. More... | |
| ~VisageFaceRecognition () | |
| Destructor. More... | |
| int | GetDescriptorSize () |
| Gets the descriptor's size. More... | |
| int | ExtractDescriptor (FaceData^facedata, VSImage^image, short[] descriptor) |
| Extracts the face descriptor for face recognition from a facial image. More... | |
| float | DescriptorsSimilarity (short[] first_descriptor, short[] second_descriptor) |
| Calculates similarity between two descriptors. More... | |
| int | AddDescriptor (VSImage^image, FaceData^facedata, System::String^name) |
| Extracts a face descriptor from the input RGB image and adds it to the gallery. More... | |
| int | AddDescriptor (short[] descriptor, System::String^name) |
| Adds a face descriptor to the gallery. More... | |
| int | GetDescriptorCount () |
| Gets number of descriptors in the gallery. More... | |
| int | GetDescriptorName (char *name, int index) |
| Gets the name of a descriptor at the given index in the gallery. More... | |
| int | ReplaceDescriptorName (const char *name, int index) |
| Replaces the name of a descriptor at the given index in the gallery with new name. More... | |
| int | RemoveDescriptor (int index) |
| Removes a descriptor at the given index from the gallery. More... | |
| int | SaveGallery (System::String^file_name) |
| Save gallery as a binary file. More... | |
| int | LoadGallery (System::String^file_name) |
| Load gallery from a binary file. More... | |
| void | ResetGallery () |
| Clear all face descriptors from the gallery. More... | |
| int | Recognize (short[] descriptor, int n, ref string[] names, float[] similarities) |
| Compare a face to all faces in the current gallery and return n names of the most similar faces. More... | |
Public Attributes | |
| property bool | IsInitialized |
| If the model used in the VisageFaceRecognition is loaded and initialized successfully value of the is_initialized variable is true, otherwise it is false. More... | |
VisageFaceRecognition class contains a face recognition algorithm capable of measuring similarity between human faces and recognizing a person's identity from frontal facial images (yaw angle approximately from -20 to 20 degrees).
The face descriptor is a condensed representation of a face. It is an array of short values. The dimension of the array is obtained using GetDescriptorSize() function, from now on in the text referred to as DESCRIPTOR_SIZE. To extract descriptors from facial image, method ExtractDescriptor() is provided. Similarity between two faces is calculated as difference between their face descriptors and returned as a value between 0 (no similarity) and 1 (maximum similarity) using DescriptorsSimilarity().
For a person to be recognized, its identity has to be stored beforehand. Database of stored face descriptors will be referred to as face recognition gallery. For smaller sets of face descriptors (up to several hundred), higher-level API for recognizing person's identity using face recognition gallery is provided. The gallery is an array of face descriptors, with a corresponding array of names, so that the gallery may contain n descriptors and a corresponding name for each descriptor. To perform recognition, the face descriptor extracted from the input image is then compared with face descriptors from the gallery and the similarity between the input face descriptor and all face descriptors from the gallery is calculated in order to find the face(s) from the gallery that are most similar to the input face. The VisageFaceRecognition class includes the following set of functions for manipulating the gallery, including adding, removing, naming descriptors in the gallery as well as loading and saving the gallery to file:
The gallery is stored as a simple txt file and as such it is not intended to be used to save large number of face descriptors. The current implementation of gallery is only a demonstration of how Face Recognition API can be used and it is recommended to implement more efficient solution for scenarios which require large face recognition gallery.
An example of face recognition gallery stored to a file is famous_actors.frg, located in Samples/OpenGL/data/ShowcaseDemo.
Definition at line 30 of file VisageFaceRecognition.cs.
| VisageCSWrapper.VisageFaceRecognition.VisageFaceRecognition | ( | System::String^ | dataPath | ) |
Constructor.
| dataPath | path to the data file required for face recognition. In the visage|SDK distribution, the file is: Samples/data/vfr/fr.bin. |
| VisageCSWrapper.VisageFaceRecognition.~VisageFaceRecognition | ( | ) |
Destructor.
| int VisageCSWrapper.VisageFaceRecognition.AddDescriptor | ( | VSImage^ | image, |
| FaceData^ | facedata, | ||
| System::String^ | name | ||
| ) |
Extracts a face descriptor from the input RGB image and adds it to the gallery.
| image | VsImage pointer that contains the input RGB image. The image should contain only one face and this face will be added to the gallery. In case of multiple faces in the image, it is not defined which face would be used. |
| facedata | Facial data obtained from VisageTracker or VisageFeaturesDetector. |
| name | Name of the face in the image. |
See also: VSImage
| int VisageCSWrapper.VisageFaceRecognition.AddDescriptor | ( | short[] | descriptor, |
| System::String^ | name | ||
| ) |
Adds a face descriptor to the gallery.
| descriptor | Pointer to the face descriptor (an array of DESCRIPTOR_SIZE short values) which will be added to the gallery. |
| name | Name of the face in the image. |
| float VisageCSWrapper.VisageFaceRecognition.DescriptorsSimilarity | ( | short[] | first_descriptor, |
| short[] | second_descriptor | ||
| ) |
Calculates similarity between two descriptors.
The function returns a float value between 0 and 1. Two descriptors are equal if the similarity is 1. Two descriptors are completely different if the similarity is 0.
| first_descriptor | Pointer to the first descriptor, an array of DESCRIPTOR_SIZE short values. |
| second_descriptor | Pointer to the second descriptor, an array of DESCRIPTOR_SIZE short values. |
| int VisageCSWrapper.VisageFaceRecognition.ExtractDescriptor | ( | FaceData^ | facedata, |
| VSImage^ | image, | ||
| short[] | descriptor | ||
| ) |
Extracts the face descriptor for face recognition from a facial image.
Prior to using this function, it is neccessary to process the facial image or video frame using VisageTracker or VisageFeaturesDetector and pass the obtained facial data to this function.
| facedata | Facial data obtained from VisageTracker or VisageFeaturesDetector. |
| image | VsImage pointer to the input RGB image. |
| descriptor | Pointer to a DESCRIPTOR_SIZE-dimensional array of short. The resulting face descriptor is returned in this array. |
See also: FaceData, VisageTracker, VisageFeaturesDetector
| int VisageCSWrapper.VisageFaceRecognition.GetDescriptorCount | ( | ) |
Gets number of descriptors in the gallery.
| int VisageCSWrapper.VisageFaceRecognition.GetDescriptorName | ( | char * | name, |
| int | index | ||
| ) |
Gets the name of a descriptor at the given index in the gallery.
| name | Buffer into which the name of a descriptor is filled. |
| index | Index of descriptor in the gallery. |
| int VisageCSWrapper.VisageFaceRecognition.GetDescriptorSize | ( | ) |
Gets the descriptor's size.
The function returns size of an array which should be allocated for storing the descriptor.
| int VisageCSWrapper.VisageFaceRecognition.LoadGallery | ( | System::String^ | file_name | ) |
Load gallery from a binary file.
The entries from the loaded gallery are appended to the current gallery. If it is required to replace existing gallery with the loaded one, call resetGallery() first.
| file_name | Name of the file (including path if needed) from which the gallery will be loaded. |
| int VisageCSWrapper.VisageFaceRecognition.Recognize | ( | short[] | descriptor, |
| int | n, | ||
| ref string[] | names, | ||
| float[] | similarities | ||
| ) |
Compare a face to all faces in the current gallery and return n names of the most similar faces.
| descriptor | Pointer to the face descriptor of the face to be recognized (compared to the gallery). |
| n | Number of names and similarities to be returned. |
| names | Pointer to an array of char arrays. In this array the function will return names of n faces from the gallery that are most similar to the input image ascending by similarity. |
| similarities | Pointer to an array of n floats. The function will return the ascending similarity values for the n most similar faces in this array corresponding to the names array. The values are sorted, with the largest similarity value first. |
| int VisageCSWrapper.VisageFaceRecognition.RemoveDescriptor | ( | int | index | ) |
Removes a descriptor at the given index from the gallery.
The remaining descriptors in the gallery above the given index (if any) are shifted down in the gallery array by one place, filling the gap created by removing the descriptor.
| index | Index of descriptor in the gallery. |
| int VisageCSWrapper.VisageFaceRecognition.ReplaceDescriptorName | ( | const char * | name, |
| int | index | ||
| ) |
Replaces the name of a descriptor at the given index in the gallery with new name.
| name | New descriptor name. |
| index | Index of descriptor in the gallery. |
| void VisageCSWrapper.VisageFaceRecognition.ResetGallery | ( | ) |
Clear all face descriptors from the gallery.
| int VisageCSWrapper.VisageFaceRecognition.SaveGallery | ( | System::String^ | file_name | ) |
Save gallery as a binary file.
| file_name | Name of the file (including path if needed) into which the gallery will be saved. |
| property bool VisageCSWrapper.VisageFaceRecognition.IsInitialized |
If the model used in the VisageFaceRecognition is loaded and initialized successfully value of the is_initialized variable is true, otherwise it is false.
Make sure the variable is set to true after instantiation and before using other function of VisageFaceRecognition API. An example of use:
Read only property.
Definition at line 187 of file VisageFaceRecognition.cs.
1.8.10