| Liveness Engine SDK Liveness detection engine.

ILiveness.h
Go to the documentation of this file.
1
8 #pragma once
9 #include <fsdk/IObject.h>
10 #include <fsdk/Types.h>
11
12 namespace lsdk {
13
23 enum LivenessAlgorithmType {
24 LA_PITCH_DOWN,
25 LA_PITCH_UP,
26 LA_YAW_LEFT,
27 LA_YAW_RIGHT,
28 LA_SMILE,
29 LA_MOUTH,
30 LA_EYEBROW,
31 LA_EYE,
32 LA_FLOW,
33 LA_INFRARED,
34 LA_COUNT
35 };
36
40 enum ComplexLivenessAlgorithmType {
41 CLA_DEPTH,
42 CLA_COUNT
43 };
44
45 enum class LSDKError : uint32_t {
46 Ok,
47 NotInitialized,
48 NotReady,
49 PreconditionFailed,
50 Internal,
51 };
52
56 struct Angles {
57 float yaw = 0.f;
58 float pitch = 0.f;
59 float roll = 0.f;
60 };
61
65 struct Scores {
66 float smile = 0.f;
67 float mouth = 0.f;
68 float eyebrow = 0.f;
69 };
70
74 struct EyeStates {
75 int left= 0;
76 int right = 0;
77 };
78
82 struct ILiveness : fsdk::IRefCounted{
83
88 virtual void reset() noexcept = 0;
89
104 virtual fsdk::ResultValue<LSDKError,bool> update(fsdk::Image& image) noexcept = 0;
105
110 virtual void runAfter(ILiveness* other) noexcept = 0;
111
117 virtual bool getDetection(fsdk::Detection* detection) noexcept = 0;
118
124 virtual bool getWarp(fsdk::Image* image) noexcept = 0;
125
131 virtual bool getLandmarks68(fsdk::Landmarks68* landmarks68) noexcept = 0;
132
138 virtual bool getLandmarks5(fsdk::Landmarks5* landmarks5) noexcept = 0;
139
145 virtual bool getIrisLandmarks(fsdk::Landmarks<32>* irisLandmarks) noexcept = 0;
146
152 virtual bool getAngles (Angles* angles) noexcept = 0;
153
159 virtual bool getScores (Scores* scores) noexcept = 0;
160
166 virtual bool getEyestates (EyeStates* eyeStates) noexcept = 0;
167
173 virtual fsdk::Result<LSDKError> loadSettings(fsdk::ISettingsProvider* provider) noexcept = 0;
174 };
175
180 template <typename T, typename... Args>
181 uint32_t field (T current, Args... rest) noexcept {
182 return field(rest...)|(1<<(uint32_t)current);
183 };
184
185 template <typename T>
186 uint32_t field(T last) noexcept {
187 return (uint32_t)(1<<(uint32_t)last);
188 }
189
197 struct IUnifiedLiveness : ILiveness {
198
211 virtual void consider(uint32_t flags) noexcept = 0;
212
217 virtual int getBlinkCounter() noexcept = 0;
218 };
219
224 struct IComplexLiveness : ILiveness {
225
242 virtual fsdk::ResultValue<LSDKError,bool> update(fsdk::Image& rgb, fsdk::Image& map) noexcept = 0;
243
244 };
245
247 }
248
249 namespace fsdk {
253 template<>
254 struct ErrorTraits<lsdk::LSDKError> {
255
256 static bool isOk(lsdk::LSDKError error) noexcept {
257 return error == lsdk::LSDKError::Ok;
258 }
259
260 static const char *toString(lsdk::LSDKError error) noexcept {
261 switch (error) {
262 case lsdk::LSDKError::Ok:
263 return "Ok";
264 case lsdk::LSDKError::Internal:
265 return "Internal error";
266 case lsdk::LSDKError::NotReady:
267 return "Liveness result is not ready.";
268 case lsdk::LSDKError::NotInitialized:
269 return "Liveness is not initialized";
270 case lsdk::LSDKError::PreconditionFailed:
271 return "Precondition failed";
272 default:
273 return "Unknown error";
274 }
275 }
276 };
277 }
lsdk::ILiveness::getIrisLandmarks
virtual bool getIrisLandmarks(fsdk::Landmarks< 32 > *irisLandmarks) noexcept=0
Get 32 iris landmarks extracted from detection from last image.
lsdk::ILiveness
Liveness detector interface.
Definition: ILiveness.h:82
lsdk::ComplexLivenessAlgorithmType
ComplexLivenessAlgorithmType
Complex liveness algorithm type enumeration.
Definition: ILiveness.h:40
lsdk::ILiveness::getWarp
virtual bool getWarp(fsdk::Image *image) noexcept=0
Get face warp retrieved from last image.
lsdk::Scores
Structure for score measurements retrieval.
Definition: ILiveness.h:65
lsdk::LA_INFRARED
ALgorithm based on infrared warp analisys.
Definition: ILiveness.h:33
fsdk
Definition: ILiveness.h:249
lsdk::ILiveness::getDetection
virtual bool getDetection(fsdk::Detection *detection) noexcept=0
Get fsdk::Detection retrieved from last image.
lsdk::ILiveness::update
virtual fsdk::ResultValue< LSDKError, bool > update(fsdk::Image &image) noexcept=0
Update liveness state according to image data.
lsdk::LSDKError::PreconditionFailed
Starting condition is not accomplished, liveness not started yet.
lsdk::CLA_DEPTH
Algorithm based on depth map analysis.
Definition: ILiveness.h:41
lsdk::LA_MOUTH
Algorithm based on mouth opening.
Definition: ILiveness.h:29
lsdk::IUnifiedLiveness
Unified liveness detector interface. This liveness type includes previous types and performs all cal...
Definition: ILiveness.h:197
lsdk::ILiveness::loadSettings
virtual fsdk::Result< LSDKError > loadSettings(fsdk::ISettingsProvider *provider) noexcept=0
Restore all apropriate settings from given prodvider.
lsdk::LSDKError::NotInitialized
Liveness not initialized.
lsdk::EyeStates
Structure for eyeStates retrieval.
Definition: ILiveness.h:74
lsdk::LA_PITCH_DOWN
Algorithm based on upward face movement.
Definition: ILiveness.h:24
lsdk::LSDKError::NotReady
Liveness not ready, require more updates.
lsdk::ILiveness::getLandmarks68
virtual bool getLandmarks68(fsdk::Landmarks68 *landmarks68) noexcept=0
Get 68 facial landmarks extracted from detection from last image.
lsdk::Angles
Structure for angle measurements retrieval.
Definition: ILiveness.h:56
lsdk::ILiveness::getAngles
virtual bool getAngles(Angles *angles) noexcept=0
Get face angles .
lsdk::IUnifiedLiveness::getBlinkCounter
virtual int getBlinkCounter() noexcept=0
Gets blink stats.
lsdk::IUnifiedLiveness::consider
virtual void consider(uint32_t flags) noexcept=0
Sets liveness types to take into consideration.
lsdk::LSDKError::Internal
Internal error.
lsdk::ILiveness::getScores
virtual bool getScores(Scores *scores) noexcept=0
Get face angles .
lsdk::CLA_COUNT
Not a type; counts number of available types.
Definition: ILiveness.h:42
lsdk
Definition: ILiveness.h:12
lsdk::LivenessAlgorithmType
LivenessAlgorithmType
Simple liveness algorithm type enumeration.
Definition: ILiveness.h:23
lsdk::LSDKError::Ok
Ok.
lsdk::IComplexLiveness
Complex liveness detector interface.
Definition: ILiveness.h:224
lsdk::IComplexLiveness::update
virtual fsdk::ResultValue< LSDKError, bool > update(fsdk::Image &rgb, fsdk::Image &map) noexcept=0
Update liveness state according to image data.
lsdk::ILiveness::getLandmarks5
virtual bool getLandmarks5(fsdk::Landmarks5 *landmarks5) noexcept=0
Get 5 facial landmarks extracted from detection from last image.
lsdk::LA_YAW_RIGHT
Algorithm based on rightward face movement.
Definition: ILiveness.h:27
lsdk::ILiveness::getEyestates
virtual bool getEyestates(EyeStates *eyeStates) noexcept=0
Get face angles .
lsdk::LA_SMILE
Algorithm based on smile.
Definition: ILiveness.h:28
lsdk::LA_EYE
Algorithm based on eye blinking.
Definition: ILiveness.h:31
lsdk::LSDKError
LSDKError
Definition: ILiveness.h:45
lsdk::LA_COUNT
Not a type; counts number of available types.
Definition: ILiveness.h:34
lsdk::LA_FLOW
Algorithm based on camera zooming.
Definition: ILiveness.h:32
lsdk::LA_EYEBROW
Algorithm based on eyebrows rising.
Definition: ILiveness.h:30
lsdk::LA_YAW_LEFT
Algorithm based on leftward face movement.
Definition: ILiveness.h:26
lsdk::ILiveness::runAfter
virtual void runAfter(ILiveness *other) noexcept=0
Configure this liveness with tracking state from other liveness.
lsdk::LA_PITCH_UP
Algorithm based on downward face movement.
Definition: ILiveness.h:25
lsdk::field
uint32_t field(T current, Args... rest) noexcept
Auxiliary function for binary field composition.
Definition: ILiveness.h:181
lsdk::ILiveness::reset
virtual void reset() noexcept=0
Reset liveness state to initial condition.