FaceDlibAttribute - Extended-Object-Detection-ROS/wiki_english GitHub Wiki
Face detection and identification attribute. Dlib is used and its install is required.
Modes | Accuracy assessment | 3D-translation | 3D-rotation | Contour extraction | Additional info |
---|---|---|---|---|---|
DE | DE | ❌ | ❌ | ❌ | <Attribute_name>:face_label |
Defines faces in an image using dlib. If a base with faces, a form prefix and an identification model are provided, then it is immediately able to perform face identification.
Not implemented.
Compares the detected face with the provided base of faces, finding the most similar face, the distance between vectors of which is less than 1-Probability. Identification is available in a separate mode if you need to use another face detector.
- Name (string, must be set) unique attribute name
- Type (string, must be "FaceDlib") attribute type
- Weight (double, default: 1) attribute weight
- Probability (double, default: 0.75) acceptable identification accuracy, a label will be assigned to the detected face only if the distance between it and the face from the base is less than 1-Probability. If the attribute is used only as a detector, then it is not used
- Contour (bool, default: true) Not used in that attribute
If you plan to use the feature only in the face detection mode, then the parameters below are not required
If any of the parameters below begins with a /, then the path is considered global, if not, then relative to the directory with the configuration file
- base_dir_path (string, default: "") Path to directory with faces. Files in the directory must be in .jpeg, .jpg, .png format. The filename will match the returned label. If the detector detects more than one face on the image in the database, they are not added to the database. At the start of the node, a set of vectors encoding faces is created, this can be a lengthy operation, therefore it is recommended to use the utility and prepare a file in advance, already with encoded faces, which can be passed to the attribute by the base_file_path parameter.
- base_file_path (string, default: "") The path to the file, already with calculated face vectors. If the path to the file and to the directory is passed, then the file is used. You can create a file using the face_dlib_descriptors_extractor utility.
- sp_path (string, default: "") The path to the face shape predictor, used to "normalize" the face. Can be downloaded from the dlib website http://dlib.net/files/shape_predictor_5_face_landmarks.dat.bz2 and unziped to the desired folder.
- net_path (string, default: "") The path to the trained face recognition model can be downloaded from the dlib website http://dlib.net/files/dlib_face_recognition_resnet_model_v1.dat.bz2 and unziped to the desired folder.
Below are shown two variants of the attribute operation, independent and with the Haar Cascade as a face detector.
<?xml version="1.0" ?>
<AttributeLib>
<Attribute Name="HaarFace" Type="HaarCascade" Cascade="cascades/mallick_haarcascade_frontalface_default.xml"/>
<Attribute Name="DlibFace" Type="FaceDlib" Probability="0.4" base_file_path="face_recognition/base_faces.db" base_dir_path="face_recognition/base_faces/" sp_path="face_recognition/shape_predictor_5_face_landmarks.dat" net_path="face_recognition/dlib_face_recognition_resnet_model_v1.dat"/>
</AttributeLib>
<SimpleObjectBase>
<SimpleObject Name="FaceRecognition1" ID="12">
<Attribute Type="Detect">DlibFace</Attribute>
</SimpleObject>
<SimpleObject Name="FaceRecognition2" ID="13">
<Attribute Type="Detect">HaarFace</Attribute>
<Attribute Type="Extract">DlibFace</Attribute>
</SimpleObject>
</SimpleObjectBase>
As you can observe, the attribute finds and recognizes face. In the case when there is no suitable person with the specified threshold, then the label Unknown is added and the contribution (score) of the attribute becomes 0. The base image with the name Moscowsky.jpg was used as a reference, which was submitted with the faces of 8 other people.