SmartFace Embedded Toolkit  4.2.1
Loading...
Searching...
No Matches
sfe_face.h
Go to the documentation of this file.
1
8#pragma once
9
10#include "sfe_core.h"
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16// FACE LANDMARKS
17#define SFE_FACE_LANDMARK_COUNT 23
18
20typedef enum SFEFaceLandmarkType {
45
47typedef struct SFEFaceLandmarks {
53 float x;
55 float y;
57
59typedef struct SFEDetectionInputSize {
61 uint32_t width;
63 uint32_t height;
65
77 const SFEDetection *detection,
78 SFEFaceLandmarks out_face_landmarks[SFE_FACE_LANDMARK_COUNT]);
79
87 const SFEFaceLandmarks face_landmarks[SFE_FACE_LANDMARK_COUNT],
88 float *out_mask_confidence);
89
101 float *face_size);
102
103// FACE TEMPLATE
104#define SFE_FACE_TEMPLATE_SIZE 522
105
107typedef struct SFEFaceTemplate {
110
118
128 const SFEDetection *detection,
129 const SFEFaceLandmarks face_landmarks[SFE_FACE_LANDMARK_COUNT],
130 SFEFaceTemplate *out_face_template);
131
138 SFEFaceTemplate *template2,
139 float *out_matching_score);
140
146 float *out_face_template_quality);
147
154 SFEFaceTemplateVersion *out_face_template_version);
155
162 uint8_t *bytes,
163 size_t *size);
164
170SFEError sfeFaceTemplateImport(const uint8_t *bytes,
171 size_t size,
172 SFEFaceTemplate *out_face_template);
173
189 SFEFaceTemplate *templates_gallery, size_t gallery_size,
190 float matching_score_threshold,
192 size_t *in_out_candidates_count, size_t thread_count);
193
212 SFEFaceTemplate *templates_gallery,
213 SFEEntity *entities_gallery, size_t gallery_size,
214 float matching_score_threshold,
215 SFEEntityIdentificationCandidate *out_candidates,
216 size_t *in_out_candidates_count,
217 size_t thread_count);
218
220typedef struct SFEFaceLiveness {
222 float score;
224
234 SFEFaceLiveness *out_liveness);
235
237typedef struct SFEFaceArea {
239 float size;
241 float area;
246
256 SFEFaceArea *out_area);
257
259typedef struct SFEFaceHeadPose {
262 float pitch;
265 float yaw;
268 float roll;
270
280 SFEFaceHeadPose *out_head_pose);
281
299 float contrast;
307
311 float age;
314 float gender;
316
325 SFEImageView image,
327 SFEFaceDemographicAttributes *out_demographic_attributes);
328
337 SFEImageView image,
339 SFEFaceQualityAttributes *out_quality_attributes);
340
346
362 SFEFaceDetectionAccuracyType detection_mode,
363 size_t min_face_size, size_t max_face_size,
364 SFEDetectionInputSize *out_input_size);
365
367typedef struct SFEFaceCrop {
376
392 float face_size_extension, float max_face_size,
393 SFEFaceCrop *out_crop);
394
395#ifdef __cplusplus
396} // extern "C"
397#endif
std::optional< std::string > solver
File containing API of sfe_core library as part of SFE Toolkit.
void * SFESolver
Solver provides an abstract interface over inference models and engines.
Definition sfe_core.h:102
void * SFEError
Error type used to hold optional error message.
Definition sfe_core.h:97
SFEError sfeFaceTemplateIdentify(SFEFaceTemplate *probe_face_template, SFEFaceTemplate *templates_gallery, size_t gallery_size, float matching_score_threshold, SFETemplateIdentificationCandidate *out_candidates, size_t *in_out_candidates_count, size_t thread_count)
Get an ordered array of SFETemplateIdentificationCandidate from tested template best matches of probe...
SFEError sfeFaceArea(SFEImageView image, SFEFaceLandmarks face_landmarks[SFE_FACE_LANDMARK_COUNT], SFEFaceArea *out_area)
Get face area.
SFEError sfeFaceSize(SFEImageView image, SFEFaceLandmarks face_landmarks[SFE_FACE_LANDMARK_COUNT], float *face_size)
Get the face size in pixels from the face landmarks and the source image. Face size is defined as a m...
SFEError sfeFaceDetectInputSize(SFEImageView image, SFEFaceDetectionAccuracyType detection_mode, size_t min_face_size, size_t max_face_size, SFEDetectionInputSize *out_input_size)
Calculation of recommended input image width and height according to desired minimal and maximal size...
SFEError sfeFaceMaskConfidence(const SFEFaceLandmarks face_landmarks[SFE_FACE_LANDMARK_COUNT], float *out_mask_confidence)
Get confidence from given landmarks if the face is wearing a face mask.
SFEFaceDetectionAccuracyType
Supported 2 detection accuracy types.
Definition sfe_face.h:342
@ SFE_FACE_DETECT_ACCURACY_TYPE_ACCURATE
Definition sfe_face.h:343
@ SFE_FACE_DETECT_ACCURACY_TYPE_BALANCED
Definition sfe_face.h:344
SFEError sfeFaceTemplateMatch(SFEFaceTemplate *template1, SFEFaceTemplate *template2, float *out_matching_score)
Match two face templates.
SFEError sfeFaceDemographicAttributes(SFESolver solver, SFEImageView image, SFEFaceLandmarks face_landmarks[SFE_FACE_LANDMARK_COUNT], SFEFaceDemographicAttributes *out_demographic_attributes)
Estimate demographic attributes (age, gender) from a face image.
SFEError sfeFaceTemplateQuality(SFEFaceTemplate *face_template, float *out_face_template_quality)
Get template quality.
#define SFE_FACE_LANDMARK_COUNT
Definition sfe_face.h:17
SFEError sfeFaceLandmarks(SFESolver solver, SFEImageView image, const SFEDetection *detection, SFEFaceLandmarks out_face_landmarks[SFE_FACE_LANDMARK_COUNT])
Detect 23 landmarks of the face detected in the area of source image marked with detection.
SFEError sfeFaceLivenessPassive(SFESolver solver, SFEImageView image, SFEFaceLandmarks face_landmarks[SFE_FACE_LANDMARK_COUNT], SFEFaceLiveness *out_liveness)
Passive liveness score calculation.
SFEError sfeFaceHeadPose(SFEImageView image, SFEFaceLandmarks face_landmarks[SFE_FACE_LANDMARK_COUNT], SFEFaceHeadPose *out_head_pose)
Calculate angle rotations of head towards camera reference frame from given landmarks.
SFEError sfeFaceCrop(SFEImageView image, SFEFaceLandmarks face_landmarks[SFE_FACE_LANDMARK_COUNT], float face_size_extension, float max_face_size, SFEFaceCrop *out_crop)
Crop the face according the given landmarks, the face size extension and the maximal face size....
SFEError sfeFaceTemplateExport(const SFEFaceTemplate *face_template, uint8_t *bytes, size_t *size)
Export face template to bytes that can be shared between Innovatrics components.
#define SFE_FACE_TEMPLATE_SIZE
Definition sfe_face.h:104
SFEError sfeFaceTemplateImport(const uint8_t *bytes, size_t size, SFEFaceTemplate *out_face_template)
Import face template from bytes; format is auto-detected (iface-template protobuf or raw ICF 522-byte...
SFEError sfeFaceEntityIdentify(SFEFaceTemplate *probe_face_template, SFEFaceTemplate *templates_gallery, SFEEntity *entities_gallery, size_t gallery_size, float matching_score_threshold, SFEEntityIdentificationCandidate *out_candidates, size_t *in_out_candidates_count, size_t thread_count)
Get an ordered array of SFEEntityIdentificationCandidate from tested template best matches of probe t...
SFEError sfeFaceTemplateExtract(SFESolver solver, SFEImageView image, const SFEDetection *detection, const SFEFaceLandmarks face_landmarks[SFE_FACE_LANDMARK_COUNT], SFEFaceTemplate *out_face_template)
Extract template from source image and given face landmarks.
SFEFaceLandmarkType
Face landmark types.
Definition sfe_face.h:20
@ SFE_FACE_LANDMARK_TYPE_NOSE_TIP
Definition sfe_face.h:29
@ SFE_FACE_LANDMARK_TYPE_LEFT_EDGE
Definition sfe_face.h:43
@ SFE_FACE_LANDMARK_TYPE_MOUTH_UPPER_EDGE
Definition sfe_face.h:35
@ SFE_FACE_LANDMARK_TYPE_NOSE_RIGHT_BOTTOM
Definition sfe_face.h:28
@ SFE_FACE_LANDMARK_TYPE_RIGHT_EYEBROW_INNER_END
Definition sfe_face.h:38
@ SFE_FACE_LANDMARK_TYPE_MOUTH_LOWER_EDGE
Definition sfe_face.h:36
@ SFE_FACE_LANDMARK_TYPE_RIGHT_EYE_CENTER
Definition sfe_face.h:22
@ SFE_FACE_LANDMARK_TYPE_LEFT_EYE_OUTER_CORNER
Definition sfe_face.h:26
@ SFE_FACE_LANDMARK_TYPE_NOSE_LEFT_BOTTOM
Definition sfe_face.h:30
@ SFE_FACE_LANDMARK_TYPE_MOUTH_RIGHT_CORNER
Definition sfe_face.h:32
@ SFE_FACE_LANDMARK_TYPE_LEFT_EYE_CENTER
Definition sfe_face.h:25
@ SFE_FACE_LANDMARK_TYPE_NOSE_BOTTOM
Definition sfe_face.h:31
@ SFE_FACE_LANDMARK_TYPE_LEFT_EYEBROW_OUTER_END
Definition sfe_face.h:40
@ SFE_FACE_LANDMARK_TYPE_MOUTH_LEFT_CORNER
Definition sfe_face.h:34
@ SFE_FACE_LANDMARK_TYPE_CHIN_TIP
Definition sfe_face.h:42
@ SFE_FACE_LANDMARK_TYPE_LEFT_EYEBROW_INNER_END
Definition sfe_face.h:39
@ SFE_FACE_LANDMARK_TYPE_RIGHT_EYEBROW_OUTER_END
Definition sfe_face.h:37
@ SFE_FACE_LANDMARK_TYPE_LEFT_EYE_INNER_CORNER
Definition sfe_face.h:24
@ SFE_FACE_LANDMARK_TYPE_RIGHT_EDGE
Definition sfe_face.h:41
@ SFE_FACE_LANDMARK_TYPE_MOUTH_CENTER
Definition sfe_face.h:33
@ SFE_FACE_LANDMARK_TYPE_RIGHT_EYE_OUTER_CORNER
Definition sfe_face.h:21
@ SFE_FACE_LANDMARK_TYPE_RIGHT_EYE_INNER_CORNER
Definition sfe_face.h:23
@ SFE_FACE_LANDMARK_TYPE_NOSE_ROOT
Definition sfe_face.h:27
SFEError sfeFaceQualityAttributes(SFEImageView image, SFEFaceLandmarks face_landmarks[SFE_FACE_LANDMARK_COUNT], SFEFaceQualityAttributes *out_quality_attributes)
Calculate face image quality attributes from given source image and landmarks data.
SFEError sfeFaceTemplateVersion(SFEFaceTemplate *face_template, SFEFaceTemplateVersion *out_face_template_version)
Get face template version.
Core detection - tagged union containing all detection types.
Detection input size struct.
Definition sfe_face.h:59
uint32_t height
Recommended image height.
Definition sfe_face.h:63
uint32_t width
Recommended image width.
Definition sfe_face.h:61
Entity type, used to group templates for entity identification. This type is compatible with uuid_v4 ...
Definition sfe_core.h:114
Candidate for identification by entity.
Definition sfe_core.h:127
Face area struct.
Definition sfe_face.h:237
float area_in_image
size of face area intersected with the whole image and relative to the whole image; value in range <0...
Definition sfe_face.h:244
float area
size of face area relative to the whole image; value in range <0,1>
Definition sfe_face.h:241
float size
absolute face size
Definition sfe_face.h:239
Face crop struct.
Definition sfe_face.h:367
SFEBoundingBox crop_box
Bounding box of cropped face including the crop extension.
Definition sfe_face.h:372
SFEImage crop_image
Image of face cropped according the crop_box.
Definition sfe_face.h:374
float face_size_extension
Defines the size of the crop as an extension of the detection bounding box.
Definition sfe_face.h:370
Demographic attributes of the detected face.
Definition sfe_face.h:309
float gender
Normalized gender score in range [-1, 1]. Values near -1 indicate male, values near 1 indicate female...
Definition sfe_face.h:314
float age
Estimated age in years.
Definition sfe_face.h:311
Face head pose struct containing angle rotations of head.
Definition sfe_face.h:259
float yaw
Face attribute representing angle rotation of head towards camera reference frame around Y-axis as pe...
Definition sfe_face.h:265
float pitch
Face attribute representing angle rotation of head towards camera reference frame around X-axis as pe...
Definition sfe_face.h:262
float roll
Face attribute representing angle rotation of head towards camera reference frame around Z-axis as pe...
Definition sfe_face.h:268
Face landmarks struct.
Definition sfe_face.h:47
float y
Y coordinate of the landmark relative to source image - range <0,1>
Definition sfe_face.h:55
SFEFaceLandmarkType landmark_type
Type of the landmark detected on the face.
Definition sfe_face.h:49
float x
X coordinate of the landmark relative to source image - range <0,1>
Definition sfe_face.h:53
float confidence
Confidence of the landmark detected on the face - range <0,1>
Definition sfe_face.h:51
Face liveness struct.
Definition sfe_face.h:220
float score
Normalized passive liveness score - range <0,1>
Definition sfe_face.h:222
Face quality attributes struct.
Definition sfe_face.h:283
float unique_intensity_levels
Normalized face attribute for evaluating whether an area of face has appropriate number of unique int...
Definition sfe_face.h:305
float sharpness
Normalized face attribute for evaluating whether an area of face image is not blurred....
Definition sfe_face.h:288
float brightness
Normalized face attribute for evaluating whether an area of face is correctly exposed....
Definition sfe_face.h:293
float contrast
Normalized face attribute for evaluating whether an area of face is contrast enough....
Definition sfe_face.h:299
Face template struct.
Definition sfe_face.h:107
uint8_t data[SFE_FACE_TEMPLATE_SIZE]
Definition sfe_face.h:108
Face template version struct.
Definition sfe_face.h:112
uint8_t version_major
major template version
Definition sfe_face.h:114
uint8_t version_minor
minor template version
Definition sfe_face.h:116
Raw owned raster image representation, HWC|BGR order.
Definition sfe_core.h:70
Candidate for identification by template.
Definition sfe_core.h:119