Enrollment 28.2.0
Loading...
Searching...
No Matches
FaceValidation.h
Go to the documentation of this file.
1
10
11#pragma once
12
15#include <float.h>
16#include <vector>
17
18namespace inno
19{
23 */
25 {
29 float min;
31 float max;
33 float value;
34
35 bool operator==(const FailedFaceAttribute& r) const
36 {
37 return id == r.id && min == r.min && max == r.max && value == r.value;
38 }
39 };
40
45 */
46 class FaceAttributeReliability
47 {
48 public:
55 virtual std::vector<FailedFaceAttribute> Validate(const std::shared_ptr<Face>& probe) = 0;
56
57 FaceAttributeReliability() = default;
58 FaceAttributeReliability(FaceAttributeReliability&&) = delete;
59 FaceAttributeReliability(const FaceAttributeReliability&) = delete;
60 FaceAttributeReliability& operator=(FaceAttributeReliability&&) = delete;
61 FaceAttributeReliability& operator=(const FaceAttributeReliability&) = delete;
62 virtual ~FaceAttributeReliability() = default;
63 };
64
68 */
69 class ICAOReliability final : public FaceAttributeReliability
70 {
71 public:
96 */
97 std::vector<FailedFaceAttribute> Validate(const std::shared_ptr<Face>& probe) final
98 {
99 if (probe == nullptr)
100 {
101 throw NullArgumentException("Probe cannot be null");
102 }
103
104 std::vector<FailedFaceAttribute> failed;
105
106 if (probe->confidence < 600)
107 {
108 failed.emplace_back(FailedFaceAttribute{
109 Face::AttributeID::CONFIDENCE, 600, 10000, static_cast<float>(probe->confidence) });
110 }
111 if (probe->YawAngle() < -10 || probe->YawAngle() > 10)
112 {
113 failed.emplace_back(FailedFaceAttribute{ Face::AttributeID::YAW_ANGLE, -10, 10, probe->YawAngle() });
114 }
115 if (probe->PitchAngle() < -10 || probe->PitchAngle() > 10)
116 {
117 failed.emplace_back(
118 FailedFaceAttribute{ Face::AttributeID::PITCH_ANGLE, -10, 10, probe->PitchAngle() });
119 }
120 if (probe->Sharpness() < 0)
121 {
122 failed.emplace_back(FailedFaceAttribute{ Face::AttributeID::SHARPNESS, 0, 10000, probe->Sharpness() });
123 }
124 if (probe->Brightness() < -5000 || probe->Brightness() > 5000)
125 {
126 failed.emplace_back(
127 FailedFaceAttribute{ Face::AttributeID::BRIGHTNESS, -5000, 5000, probe->Brightness() });
128 }
129 if (probe->Contrast() < -5000 || probe->Contrast() > 5000)
130 {
131 failed.emplace_back(FailedFaceAttribute{ Face::AttributeID::CONTRAST, -5000, 5000, probe->Contrast() });
132 }
133 if (probe->UniqueIntensityLevels() < 0)
134 {
135 failed.emplace_back(FailedFaceAttribute{
136 Face::AttributeID::UNIQUE_INTENSITY_LEVELS, 0, 10000, probe->UniqueIntensityLevels() });
137 }
138 if (probe->Shadow() < -200)
139 {
140 failed.emplace_back(FailedFaceAttribute{ Face::AttributeID::SHADOW, -200, 10000, probe->Shadow() });
141 }
142 if (probe->NoseShadow() < -80)
143 {
144 failed.emplace_back(
145 FailedFaceAttribute{ Face::AttributeID::NOSE_SHADOW, -80, 10000, probe->NoseShadow() });
146 }
147 if (probe->Specularity() < -100)
148 {
149 failed.emplace_back(
150 FailedFaceAttribute{ Face::AttributeID::SPECULARITY, -100, 10000, probe->Specularity() });
151 }
152 if (probe->HeavyFrame() > 300)
153 {
154 failed.emplace_back(
155 FailedFaceAttribute{ Face::AttributeID::HEAVY_FRAME, -10000, 300, probe->HeavyFrame() });
156 }
157 if (probe->MouthStatus() < 0)
158 {
159 failed.emplace_back(
160 FailedFaceAttribute{ Face::AttributeID::MOUTH_STATUS, 0, 10000, probe->MouthStatus() });
161 }
162 if (probe->BackgroundUniformity() < -1000)
163 {
164 failed.emplace_back(FailedFaceAttribute{
165 Face::AttributeID::BACKGROUND_UNIFORMITY, -1000, 10000, probe->BackgroundUniformity() });
166 }
167 if (probe->RollAngle() < -10 || probe->RollAngle() > 10)
168 {
169 failed.emplace_back(FailedFaceAttribute{ Face::AttributeID::ROLL_ANGLE, -10, 10, probe->RollAngle() });
170 }
171 if (probe->RightEyeStatus() < 0)
172 {
173 failed.emplace_back(
174 FailedFaceAttribute{ Face::AttributeID::RIGHT_EYE_STATUS, 0, 10000, probe->RightEyeStatus() });
175 }
176 if (probe->LeftEyeStatus() < 0)
177 {
178 failed.emplace_back(
179 FailedFaceAttribute{ Face::AttributeID::LEFT_EYE_STATUS, 0, 10000, probe->LeftEyeStatus() });
180 }
181 if (constexpr int MaxRedEye = 0; probe->RightRedEye() > MaxRedEye)
182 {
183 failed.emplace_back(
184 FailedFaceAttribute{ Face::AttributeID::RIGHT_RED_EYE, -10000, MaxRedEye, probe->RightRedEye() });
185 }
186 if (constexpr int MaxRedEye = 0; probe->LeftRedEye() > MaxRedEye)
187 {
188 failed.emplace_back(
189 FailedFaceAttribute{ Face::AttributeID::LEFT_RED_EYE, -10000, MaxRedEye, probe->LeftRedEye() });
190 }
191 if (constexpr int MinGaze = -400; probe->EyeGaze() < MinGaze)
192 {
193 failed.emplace_back(
194 FailedFaceAttribute{ Face::AttributeID::EYE_GAZE, MinGaze, 10000, probe->EyeGaze() });
195 }
196 return failed;
197 }
198
199 ICAOReliability() = default;
201 ICAOReliability(const ICAOReliability&) = delete;
202 ICAOReliability& operator=(ICAOReliability&&) = delete;
203 ICAOReliability& operator=(const ICAOReliability&) = delete;
204 virtual ~ICAOReliability() = default;
205 };
206
210 */
211 class TemplateReliability final : public FaceAttributeReliability
212 {
213 public:
220 */
221 std::vector<FailedFaceAttribute> Validate(const std::shared_ptr<Face>& probe) final
222 {
223 if (probe == nullptr)
224 {
225 throw NullArgumentException("Probe cannot be null");
226 }
227
228 std::vector<FailedFaceAttribute> failed;
229
230 if (probe->confidence < 600)
231 {
232 failed.emplace_back(FailedFaceAttribute{
233 Face::AttributeID::CONFIDENCE, 600, 10000, static_cast<float>(probe->confidence) });
234 }
235
236 return failed;
237 }
238
239 TemplateReliability() = default;
242 TemplateReliability& operator=(TemplateReliability&&) = delete;
243 TemplateReliability& operator=(const TemplateReliability&) = delete;
244 virtual ~TemplateReliability() = default;
245 };
246
250 */
251 class AgeReliability final : public FaceAttributeReliability
252 {
253 public:
260 */
261 std::vector<FailedFaceAttribute> Validate(const std::shared_ptr<Face>& probe) final
262 {
263 if (probe == nullptr)
264 {
265 throw NullArgumentException("Probe cannot be null");
266 }
267
268 std::vector<FailedFaceAttribute> failed;
269
270 if (probe->confidence < 600)
271 {
272 failed.emplace_back(FailedFaceAttribute{
273 Face::AttributeID::CONFIDENCE, 600, 10000, static_cast<float>(probe->confidence) });
274 }
275 if (probe->FaceSize() < 36)
276 {
277 failed.emplace_back(
278 FailedFaceAttribute{ Face::AttributeID::FACE_SIZE, 36, FLT_MAX, probe->FaceSize() });
279 }
280 if (probe->YawAngle() < -20 || probe->YawAngle() > 20)
281 {
282 failed.emplace_back(FailedFaceAttribute{ Face::AttributeID::YAW_ANGLE, -20, 20, probe->YawAngle() });
283 }
284 if (probe->PitchAngle() < -15 || probe->PitchAngle() > 15)
285 {
286 failed.emplace_back(
287 FailedFaceAttribute{ Face::AttributeID::PITCH_ANGLE, -15, 15, probe->PitchAngle() });
288 }
289
290 return failed;
291 }
292
293 AgeReliability() = default;
294 AgeReliability(AgeReliability&&) = delete;
295 AgeReliability(const AgeReliability&) = delete;
296 AgeReliability& operator=(AgeReliability&&) = delete;
297 AgeReliability& operator=(const AgeReliability&) = delete;
298 virtual ~AgeReliability() = default;
299 };
300
304 */
305 class GlassStatusReliability final : public FaceAttributeReliability
306 {
307 public:
313 */
314 std::vector<FailedFaceAttribute> Validate(const std::shared_ptr<Face>& probe) final
315 {
316 if (probe == nullptr)
317 {
318 throw NullArgumentException("Probe cannot be null");
319 }
320
321 std::vector<FailedFaceAttribute> failed;
322
323 if (probe->confidence < 600)
324 {
325 failed.emplace_back(FailedFaceAttribute{
326 Face::AttributeID::CONFIDENCE, 600, 10000, static_cast<float>(probe->confidence) });
327 }
328 if (probe->YawAngle() < -40 || probe->YawAngle() > 40)
329 {
330 failed.emplace_back(FailedFaceAttribute{ Face::AttributeID::YAW_ANGLE, -40, 40, probe->YawAngle() });
331 }
332 if (probe->PitchAngle() < -40 || probe->PitchAngle() > 40)
333 {
334 failed.emplace_back(
335 FailedFaceAttribute{ Face::AttributeID::PITCH_ANGLE, -40, 40, probe->PitchAngle() });
336 }
337
338 return failed;
339 }
340
341 GlassStatusReliability() = default;
344 GlassStatusReliability& operator=(GlassStatusReliability&&) = delete;
345 GlassStatusReliability& operator=(const GlassStatusReliability&) = delete;
346 virtual ~GlassStatusReliability() = default;
347 };
348
352 */
353 class TintedGlassesReliability final : public FaceAttributeReliability
354 {
355 public:
362 */
363 std::vector<FailedFaceAttribute> Validate(const std::shared_ptr<Face>& probe) final
364 {
365 if (probe == nullptr)
366 {
367 throw NullArgumentException("Probe cannot be null");
368 }
369
370 std::vector<FailedFaceAttribute> failed;
371
372 if (probe->confidence < 600)
373 {
374 failed.emplace_back(FailedFaceAttribute{
375 Face::AttributeID::CONFIDENCE, 600, 10000, static_cast<float>(probe->confidence) });
376 }
377 if (probe->YawAngle() < -40 || probe->YawAngle() > 40)
378 {
379 failed.emplace_back(FailedFaceAttribute{ Face::AttributeID::YAW_ANGLE, -40, 40, probe->YawAngle() });
380 }
381 if (probe->PitchAngle() < -40 || probe->PitchAngle() > 40)
382 {
383 failed.emplace_back(
384 FailedFaceAttribute{ Face::AttributeID::PITCH_ANGLE, -40, 40, probe->PitchAngle() });
385 }
386
387 return failed;
388 }
389
390 TintedGlassesReliability() = default;
394 TintedGlassesReliability& operator=(const TintedGlassesReliability&) = delete;
395 virtual ~TintedGlassesReliability() = default;
396 };
397
402 */
403 class SegmentationMaskReliability final : public FaceAttributeReliability
404 {
405 public:
412 */
413 std::vector<FailedFaceAttribute> Validate(const std::shared_ptr<Face>& probe) final
414 {
415 if (probe == nullptr)
416 {
417 throw NullArgumentException("Probe cannot be null");
418 }
419
420 std::vector<FailedFaceAttribute> failed;
421
422 if (probe->confidence < 600)
423 {
424 failed.emplace_back(FailedFaceAttribute{
425 Face::AttributeID::CONFIDENCE, 600, 10000, static_cast<float>(probe->confidence) });
426 }
427 if (probe->YawAngle() < -10 || probe->YawAngle() > 10)
428 {
429 failed.emplace_back(FailedFaceAttribute{ Face::AttributeID::YAW_ANGLE, -10, 10, probe->YawAngle() });
430 }
431 if (probe->PitchAngle() < -10 || probe->PitchAngle() > 10)
432 {
433 failed.emplace_back(
434 FailedFaceAttribute{ Face::AttributeID::PITCH_ANGLE, -10, 10, probe->PitchAngle() });
435 }
436
437 return failed;
438 }
439
440 SegmentationMaskReliability() = default;
445 virtual ~SegmentationMaskReliability() = default;
446 };
447
451 */
452 class FaceSizeReliability final : public FaceAttributeReliability
453 {
454 public:
461 */
462 std::vector<FailedFaceAttribute> Validate(const std::shared_ptr<Face>& probe) final
463 {
464 if (probe == nullptr)
465 {
466 throw NullArgumentException("Probe cannot be null");
467 }
468
469 std::vector<FailedFaceAttribute> failed;
470
471 if (probe->confidence < 600)
472 {
473 failed.emplace_back(FailedFaceAttribute{
474 Face::AttributeID::CONFIDENCE, 600, 10000, static_cast<float>(probe->confidence) });
475 }
476
477 return failed;
478 }
479
480 FaceSizeReliability() = default;
483 FaceSizeReliability& operator=(FaceSizeReliability&&) = delete;
484 FaceSizeReliability& operator=(const FaceSizeReliability&) = delete;
485 virtual ~FaceSizeReliability() = default;
486 };
487
491 */
492 class MouthOpennessReliability final : public FaceAttributeReliability
493 {
494 public:
501 */
502 std::vector<FailedFaceAttribute> Validate(const std::shared_ptr<Face>& probe) final
503 {
504 if (probe == nullptr)
505 {
506 throw NullArgumentException("Probe cannot be null");
507 }
508
509 std::vector<FailedFaceAttribute> failed;
510
511 if (probe->confidence < 600)
512 {
513 failed.emplace_back(FailedFaceAttribute{
514 Face::AttributeID::CONFIDENCE, 600, 10000, static_cast<float>(probe->confidence) });
515 }
516 if (probe->YawAngle() < -30 || probe->YawAngle() > 30)
517 {
518 failed.emplace_back(FailedFaceAttribute{ Face::AttributeID::YAW_ANGLE, -30, 30, probe->YawAngle() });
519 }
520 if (probe->PitchAngle() < -30 || probe->PitchAngle() > 30)
521 {
522 failed.emplace_back(
523 FailedFaceAttribute{ Face::AttributeID::PITCH_ANGLE, -30, 30, probe->PitchAngle() });
524 }
525
526 return failed;
527 }
528
529 MouthOpennessReliability() = default;
533 MouthOpennessReliability& operator=(const MouthOpennessReliability&) = delete;
534 virtual ~MouthOpennessReliability() = default;
535 };
536
540 */
541 class UniversalPassiveLivenessReliability final : public FaceAttributeReliability
542 {
543 public:
551 */
552 std::vector<FailedFaceAttribute> Validate(const std::shared_ptr<Face>& probe) final
553 {
554 if (probe == nullptr)
555 {
556 throw NullArgumentException("Probe cannot be null");
557 }
558
559 std::vector<FailedFaceAttribute> failed;
560 constexpr unsigned int MinAllowedConfidence = 1000;
561 constexpr unsigned int MaxAllowedConfidence = 10000;
562 if (probe->confidence < MinAllowedConfidence)
563 {
565 MinAllowedConfidence,
566 MaxAllowedConfidence,
567 static_cast<float>(probe->confidence) });
568 }
569
570 return failed;
571 }
572
578 virtual ~UniversalPassiveLivenessReliability() = default;
579 };
580
590 */
591 class ISOFullFrontalImageValidator final : public FaceAttributeReliability
592 {
593 public:
600 */
601 std::vector<FailedFaceAttribute> Validate(const std::shared_ptr<Face>& probe) final
602 {
603 if (probe == nullptr)
604 {
605 throw NullArgumentException("Probe cannot be null");
606 }
607
608 std::vector<FailedFaceAttribute> failed;
609
610 constexpr float MinRatio = 1.F / 1.34F;
611 constexpr float MaxRatio = 1.F / 1.25F;
612 if ((probe->WidthHeightRatio() < MinRatio || probe->WidthHeightRatio() > MaxRatio))
613 {
614 failed.emplace_back(FailedFaceAttribute{
615 Face::AttributeID::WIDTH_HEIGHT_RATIO, MinRatio, MaxRatio, probe->WidthHeightRatio() });
616 }
617 return failed;
618 }
619
625 virtual ~ISOFullFrontalImageValidator() = default;
626 };
627
628} // namespace inno
Check if calculation of Age attribute will be reliable.
Definition FaceValidation.h:251
std::vector< FailedFaceAttribute > Validate(const std::shared_ptr< Face > &probe) final
Check if calculation of Age attribute will be reliable.
Definition FaceValidation.h:260
virtual std::vector< FailedFaceAttribute > Validate(const std::shared_ptr< Face > &probe)=0
Check if face is reliable to calculate attribute.
Check if calculation of Face Size attribute will be reliable.
Definition FaceValidation.h:452
std::vector< FailedFaceAttribute > Validate(const std::shared_ptr< Face > &probe) final
Check if calculation of Face Size attribute will be reliable.
Definition FaceValidation.h:461
AttributeID
Face attributes IDs.
Definition Face.h:1852
@ LEFT_RED_EYE
Attribute for evaluating whether red-eye effect is not present on left eye.
Definition Face.h:1906
@ LEFT_EYE_STATUS
Attribute for evaluating left eye status.
Definition Face.h:1885
@ BACKGROUND_UNIFORMITY
Attribute used to measure background uniformity in the close area around the detected face in the ori...
Definition Face.h:1897
@ BRIGHTNESS
Brightness attribute used to measure the brightness level of an area of the detected face in the orig...
Definition Face.h:1861
@ SHARPNESS
Sharpness attribute used to measure the sharpness level of an area of the detected face in the origin...
Definition Face.h:1858
@ WIDTH_HEIGHT_RATIO
Attribute representing width to height aspect ratio of the original face capture.
Definition Face.h:1936
@ YAW_ANGLE
Attribute representing the head rotation angle around the Y-axis of the detected face in the original...
Definition Face.h:1921
@ PITCH_ANGLE
Attribute representing the head rotation angle around the X-axis of the detected face in the original...
Definition Face.h:1918
@ MOUTH_STATUS
Attribute for evaluating mouth status.
Definition Face.h:1894
@ SHADOW
Shadow attribute used to evaluate whether an area of the detected face in the original face capture i...
Definition Face.h:1870
@ FACE_SIZE
Attribute representing face size - the maximum of eye distance and eye-mouth distance.
Definition Face.h:1924
@ CONFIDENCE
Provides confidence score of the face related to face detection.
Definition Face.h:1855
@ RIGHT_RED_EYE
Attribute for evaluating whether red-eye effect is not present on right eye.
Definition Face.h:1903
@ SPECULARITY
Specularity attribute used to evaluate the presence of spotlights in an area of the detected face in ...
Definition Face.h:1876
@ ROLL_ANGLE
Attribute representing the head rotation angle around the Z-axis of the detected face in the original...
Definition Face.h:1915
@ NOSE_SHADOW
Nose Shadow attribute for evaluating whether eyes or a nose don't cast sharp shadows.
Definition Face.h:1873
@ HEAVY_FRAME
Attribute for evaluating whether glasses with heavy frames are not present.
Definition Face.h:1891
@ UNIQUE_INTENSITY_LEVELS
Unique Intensity Levels attribute used to measure whether an area of the detected face in the origina...
Definition Face.h:1867
@ EYE_GAZE
Eye Gaze attribute used to evaluate whether the gaze direction of the detected face in the original f...
Definition Face.h:1879
@ RIGHT_EYE_STATUS
Attribute for evaluating right eye status.
Definition Face.h:1882
@ CONTRAST
Contrast attribute used to measure the contrast level of an area of the detected face in the original...
Definition Face.h:1864
Check if calculation of Glass Status attribute will be reliable.
Definition FaceValidation.h:305
std::vector< FailedFaceAttribute > Validate(const std::shared_ptr< Face > &probe) final
Check if calculation of Glass Status attribute will be reliable.
Definition FaceValidation.h:313
Check if Face will fullfil ICAO requirements.
Definition FaceValidation.h:69
std::vector< FailedFaceAttribute > Validate(const std::shared_ptr< Face > &probe) final
Check if Face will fullfil ICAO requirements.
Definition FaceValidation.h:96
Check if usage of Full Frontal Images on travel documents will follow best practices,...
Definition FaceValidation.h:591
std::vector< FailedFaceAttribute > Validate(const std::shared_ptr< Face > &probe) final
Check if usage of Full Frontal image on travel documents will be reliable.
Definition FaceValidation.h:600
Check if calculation of Mouth Openness attribute will be reliable.
Definition FaceValidation.h:492
std::vector< FailedFaceAttribute > Validate(const std::shared_ptr< Face > &probe) final
Check if calculation of Mouth Openness attribute will be reliable.
Definition FaceValidation.h:501
Null argument is not allowed.
Definition EnrollmentException.h:156
Check if calculation of Segmentation Mask in functions Face::FaceAreaSegment, Face::FaceAreaSegment(R...
Definition FaceValidation.h:403
std::vector< FailedFaceAttribute > Validate(const std::shared_ptr< Face > &probe) final
Check if calculation of Segmentation Mask in functions Face::FaceAreaSegment, Face::FaceAreaSegment(R...
Definition FaceValidation.h:412
Check if template extraction will be reliable.
Definition FaceValidation.h:211
std::vector< FailedFaceAttribute > Validate(const std::shared_ptr< Face > &probe) final
Check if template extraction will be reliable.
Definition FaceValidation.h:220
Check if calculation of Tinted Glasses attribute will be reliable.
Definition FaceValidation.h:353
std::vector< FailedFaceAttribute > Validate(const std::shared_ptr< Face > &probe) final
Check if calculation of Tinted Glasses attribute will be reliable.
Definition FaceValidation.h:362
Check if calculation of Universal passive liveness will be reliable.
Definition FaceValidation.h:541
std::vector< FailedFaceAttribute > Validate(const std::shared_ptr< Face > &probe) final
Check if calculation of Universal passive liveness will be reliable.
Definition FaceValidation.h:551
It contains attribute data that express which and why attribute fails in reliability check.
Definition FaceValidation.h:24
float value
Current value of attribute.
Definition FaceValidation.h:32
Face::AttributeID id
FaceAttributeID of failed attribute.
Definition FaceValidation.h:26
float max
Maximal value of attribute.
Definition FaceValidation.h:30
float min
Minimal value of attribute.
Definition FaceValidation.h:28