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 
34  };
35 
42  };
43 
44  enum class LSDKError : uint32_t {
45  Ok,
47  NotReady,
49  Internal,
50  };
51 
55  struct Angles {
56  float yaw = 0.f;
57  float pitch = 0.f;
58  float roll = 0.f;
59  };
60 
64  struct Scores {
65  float smile = 0.f;
66  float mouth = 0.f;
67  float eyebrow = 0.f;
68  };
69 
73  struct EyeStates {
74  int left = 0;
75  int right = 0;
76  };
77 
81  struct ILiveness : fsdk::IRefCounted {
82 
87  virtual void reset() noexcept = 0;
88 
103  virtual fsdk::ResultValue<LSDKError, bool> update(fsdk::Image& image) noexcept = 0;
104 
109  virtual void runAfter(ILiveness* other) noexcept = 0;
110 
116  virtual bool getDetection(fsdk::Detection* detection) noexcept = 0;
117 
123  virtual bool getWarp(fsdk::Image* image) noexcept = 0;
124 
130  virtual bool getLandmarks68(fsdk::Landmarks68* landmarks68) noexcept = 0;
131 
137  virtual bool getLandmarks5(fsdk::Landmarks5* landmarks5) noexcept = 0;
138 
144  virtual bool getIrisLandmarks(fsdk::Landmarks<32>* irisLandmarks) noexcept = 0;
145 
151  virtual bool getAngles(Angles* angles) noexcept = 0;
152 
158  virtual bool getScores(Scores* scores) noexcept = 0;
159 
165  virtual bool getEyestates(EyeStates* eyeStates) noexcept = 0;
166 
172  virtual fsdk::Result<LSDKError> loadSettings(fsdk::ISettingsProvider* provider) noexcept = 0;
173  };
174 
179  template <typename T, typename... Args>
180  uint32_t field(T current, Args... rest) noexcept {
181  return field(rest...) | (1 << (uint32_t)current);
182  }
183 
184  template <typename T>
185  uint32_t field(T last) noexcept {
186  return (uint32_t)(1 << (uint32_t)last);
187  }
188 
197 
210  virtual void consider(uint32_t flags) noexcept = 0;
211 
216  virtual int getBlinkCounter() noexcept = 0;
217  };
218 
225 
242  virtual fsdk::ResultValue<LSDKError, bool> update(fsdk::Image& rgb, fsdk::Image& map) noexcept = 0;
243  };
244 
246 } // namespace lsdk
247 
248 namespace fsdk {
252  template <>
253  struct ErrorTraits<lsdk::LSDKError> {
254 
255  static bool isOk(lsdk::LSDKError error) noexcept {
256  return error == lsdk::LSDKError::Ok;
257  }
258 
259  static const char* toString(lsdk::LSDKError error) noexcept {
260  switch(error) {
261  case lsdk::LSDKError::Ok:
262  return "Ok";
264  return "Internal error";
266  return "Liveness result is not ready.";
268  return "Liveness is not initialized";
270  return "Precondition failed";
271  default:
272  return "Unknown error";
273  }
274  }
275  };
276 } // namespace fsdk
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:81
ComplexLivenessAlgorithmType
Complex liveness algorithm type enumeration.
Definition: ILiveness.h:39
virtual bool getWarp(fsdk::Image *image) noexcept=0
Get face warp retrieved from last image.
Structure for score measurements retrieval.
Definition: ILiveness.h:64
Algorithm based on infrared warp analysis.
Definition: ILiveness.h:32
virtual bool getDetection(fsdk::Detection *detection) noexcept=0
Get fsdk::Detection retrieved from last image.
Starting condition is not accomplished, liveness not started yet.
Algorithm based on depth map analysis.
Definition: ILiveness.h:40
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:196
virtual fsdk::Result< LSDKError > loadSettings(fsdk::ISettingsProvider *provider) noexcept=0
Restore all appropriate settings from given provider.
Liveness not initialized.
Structure for eyeStates retrieval.
Definition: ILiveness.h:73
virtual fsdk::ResultValue< LSDKError, bool > update(fsdk::Image &rgb, fsdk::Image &map) noexcept=0
Update liveness state according to image data.
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:55
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:180
virtual bool getScores(Scores *scores) noexcept=0
Get face angles .
Not a type; counts number of available types.
Definition: ILiveness.h:41
LivenessAlgorithmType
Simple liveness algorithm type enumeration.
Definition: ILiveness.h:23
Complex liveness detector interface.
Definition: ILiveness.h:224
virtual bool getLandmarks5(fsdk::Landmarks5 *landmarks5) noexcept=0
Get 5 facial landmarks extracted from detection from last image.
virtual fsdk::ResultValue< LSDKError, bool > update(fsdk::Image &image) noexcept=0
Update liveness state according to image data.
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:44
Not a type; counts number of available types.
Definition: ILiveness.h:33
Algorithm based on eyebrows rising.
Definition: ILiveness.h:30
Algorithm based on leftward face movement.
Definition: ILiveness.h:26
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.