Liveness Engine SDK
Liveness detection engine.
 All Classes Files Functions Enumerations Enumerator Groups Pages
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 
35  };
36 
43  };
44 
45  enum class LSDKError : uint32_t {
46  Ok,
48  NotReady,
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 
198 
211  virtual void consider(uint32_t flags) noexcept = 0;
212 
217  virtual int getBlinkCounter() noexcept = 0;
218  };
219 
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";
265  return "Internal error";
267  return "Liveness result is not ready.";
269  return "Liveness is not initialized";
271  return "Precondition failed";
272  default:
273  return "Unknown error";
274  }
275  }
276  };
277 }
virtual bool getIrisLandmarks(fsdk::Landmarks< 32 > *irisLandmarks) noexcept=0
Get 32 iris landmarks extracted from detection from last image.
Liveness detector interface.
Definition: ILiveness.h:82
ComplexLivenessAlgorithmType
Complex liveness algorithm type enumeration.
Definition: ILiveness.h:40
virtual bool getWarp(fsdk::Image *image) noexcept=0
Get face warp retrieved from last image.
Structure for score measurements retrieval.
Definition: ILiveness.h:65
ALgorithm based on infrared warp analisys.
Definition: ILiveness.h:33
virtual bool getDetection(fsdk::Detection *detection) noexcept=0
Get fsdk::Detection retrieved from last image.
virtual fsdk::ResultValue< LSDKError, bool > update(fsdk::Image &image) noexcept=0
Update liveness state according to image data.
Starting condition is not accomplished, liveness not started yet.
Algorithm based on depth map analysis.
Definition: ILiveness.h:41
Algorithm based on mouth opening.
Definition: ILiveness.h:29
Unified liveness detector interface. This liveness type includes previous types and performs all cal...
Definition: ILiveness.h:197
virtual fsdk::Result< LSDKError > loadSettings(fsdk::ISettingsProvider *provider) noexcept=0
Restore all apropriate settings from given prodvider.
Liveness not initialized.
Structure for eyeStates retrieval.
Definition: ILiveness.h:74
Algorithm based on upward face movement.
Definition: ILiveness.h:24
Liveness not ready, require more updates.
virtual bool getLandmarks68(fsdk::Landmarks68 *landmarks68) noexcept=0
Get 68 facial landmarks extracted from detection from last image.
Structure for angle measurements retrieval.
Definition: ILiveness.h:56
virtual bool getAngles(Angles *angles) noexcept=0
Get face angles .
virtual int getBlinkCounter() noexcept=0
Gets blink stats.
virtual void consider(uint32_t flags) noexcept=0
Sets liveness types to take into consideration.
uint32_t field(T current, Args...rest) noexcept
Auxiliary function for binary field composition.
Definition: ILiveness.h:181
virtual bool getScores(Scores *scores) noexcept=0
Get face angles .
Not a type; counts number of available types.
Definition: ILiveness.h:42
LivenessAlgorithmType
Simple liveness algorithm type enumeration.
Definition: ILiveness.h:23
Complex liveness detector interface.
Definition: ILiveness.h:224
virtual fsdk::ResultValue< LSDKError, bool > update(fsdk::Image &rgb, fsdk::Image &map) noexcept=0
Update liveness state according to image data.
virtual bool getLandmarks5(fsdk::Landmarks5 *landmarks5) noexcept=0
Get 5 facial landmarks extracted from detection from last image.
Algorithm based on rightward face movement.
Definition: ILiveness.h:27
virtual bool getEyestates(EyeStates *eyeStates) noexcept=0
Get face angles .
Algorithm based on smile.
Definition: ILiveness.h:28
Algorithm based on eye blinking.
Definition: ILiveness.h:31
LSDKError
Definition: ILiveness.h:45
Not a type; counts number of available types.
Definition: ILiveness.h:34
Algorithm based on eyebrows rising.
Definition: ILiveness.h:30
Algorithm based on leftward face movement.
Definition: ILiveness.h:26
Algorithm based on camera zooming.
Definition: ILiveness.h:32
virtual void runAfter(ILiveness *other) noexcept=0
Configure this liveness with tracking state from other liveness.
Algorithm based on downward face movement.
Definition: ILiveness.h:25
virtual void reset() noexcept=0
Reset liveness state to initial condition.