Face Engine SDK  5.17.0
A face detection, recognition and tracking engine.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
IDetector.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include <fsdk/FSDKError.h>
11 #include <fsdk/IFaceDetectionBatch.h>
12 #include <fsdk/IObject.h>
13 #include <fsdk/Types.h>
14 #include <fsdk/Types/Face.h>
15 #include <fsdk/Types/SensorType.h>
16 
17 #include <fsdk/vlc/future.h>
18 
19 #include <functional>
20 
21 namespace fsdk {
22 
23 #ifndef DOXYGEN_SHOULD_SKIP_THIS
24  DECLARE_SMARTPTR(IDetector);
25 #endif
26 
43  };
44 
53  DCT_COUNT
54  };
55 
60  DT_BBOX = 0,
61  DT_LANDMARKS5 = 1<<0,
62  DT_LANDMARKS68 = 1<<1,
63  DT_ALL = 0xffff
64  };
65 
66  inline DetectionType operator | (DetectionType a, DetectionType b)
67  { return static_cast<DetectionType>(static_cast<int>(a) | static_cast<int>(b)); }
68 
73  public:
74  virtual bool compare(const Image& img, const Detection& a, const Detection& b) const = 0;
75  virtual ~IDetectionComparer() = default;
76  };
77 
82  public:
83  typedef std::function<bool(const Image& img, const Detection&, const Detection&)> Function;
84  explicit FunctionDetectionComparer(const Function& function) : func(function)
85  {}
86  bool compare(const Image& img, const Detection& a, const Detection& b) const
87  { return func(img, a, b); }
88  private:
89  Function func;
90  };
91 
109  detect(
110  Span<const Image> images,
111  Span<const Rect> ROIs,
112  uint32_t perImageNum,
113  DetectionType type = DT_BBOX
114  ) noexcept = 0;
115 
126  detectOne(
127  const Image& image,
128  const Rect& rect,
129  DetectionType type = DT_BBOX) noexcept = 0;
130 
148  redetect(
149  Span<const Image> images,
150  Ref<IFaceDetectionBatch> detectionBatch,
151  DetectionType type = DT_BBOX
152  ) noexcept = 0;
153 
170  redetect(
171  Span<const Image> images,
172  Span<Span<const Detection>> detections,
173  DetectionType type = DT_BBOX
174  ) noexcept = 0;
175 
186  redetectOne(
187  const Image& image,
188  const Detection& detection,
189  DetectionType type = DT_BBOX) noexcept = 0;
190 
196  virtual void setDetectionComparer(DetectionComparerType comparerType) noexcept = 0;
197 
204  virtual void setCustomDetectionComparer(const IDetectionComparer* comparer) noexcept = 0;
205 
219  virtual Result<FSDKError>
220  validate(
221  Span<const Image> images,
222  Span<Span<const Detection>> detections,
223  Span<Span<Result<FSDKError>>> errors) const noexcept = 0;
224 
237  virtual Result<FSDKError>
238  validate(
239  Span<const Image> images,
240  Span<const Rect> rects,
241  uint32_t detectionPerImageNum,
242  Span<Result<FSDKError>> outErrors) const noexcept = 0;
243 
256  virtual Result<FSDKError>
257  validate(
258  Span<const Image> images,
259  Ref<IFaceDetectionBatch> detectionBatch,
260  Span<Result<FSDKError>> outErrors) const noexcept = 0;
261 
265  using FaceBatchFuture = vlc::future<IFaceDetectionBatchPtr>;
266 
283  Span<const Image> images,
284  Span<const Rect> rectangles,
285  uint32_t perImageNum,
286  DetectionType type = DT_BBOX) const = 0;
287 
308  Span<const Image> images,
309  IFaceDetectionBatchPtr detectionBatch,
310  DetectionType type = DT_BBOX) const = 0;
311  };
312 
315 }
virtual ResultValue< FSDKError, Ref< IFaceDetectionBatch > > redetect(Span< const Image > images, Ref< IFaceDetectionBatch > detectionBatch, DetectionType type=DT_BBOX) noexcept=0
Batched redetect faces on multiple images. based on the detection results for the previous frames...
virtual Result< FSDKError > validate(Span< const Image > images, Span< Span< const Detection >> detections, Span< Span< Result< FSDKError >>> errors) const noexcept=0
Validate input of multiple frames in a single function call.
Syntax sugar, allows you to use lambdas to define a BestDetection comparer.
Definition: IDetector.h:81
Detector type 2.
Definition: IDetector.h:39
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:56
BestDetection - most centered detection.
Definition: IDetector.h:50
Default detector cpecified in config file.
Definition: IDetector.h:37
A structure that encapsulates an action result enumeration.
Definition: Result.h:27
Common data types and structures.
virtual void setCustomDetectionComparer(const IDetectionComparer *comparer) noexcept=0
Set custom detection comparer object.
Detector type 3.
Definition: IDetector.h:40
Smart pointer for reference counted objects.
Definition: Ref.h:26
Object system types and interfaces.
Get bounding boxes of faces.
Definition: IDetector.h:60
Common SDK error codes.
DetectionComparerType
Strategy of BestDetections comparer.
Definition: IDetector.h:48
vlc::future< IFaceDetectionBatchPtr > FaceBatchFuture
Common alias for IDetector asynchronous interface.
Definition: IDetector.h:265
Detector type count.
Definition: IDetector.h:42
virtual ResultValue< FSDKError, Face > detectOne(const Image &image, const Rect &rect, DetectionType type=DT_BBOX) noexcept=0
Light function to get just one best detection from single input image.
Base strong reference counted object interface.
Definition: IRefCounted.h:37
face detector interface.
Definition: IDetector.h:95
virtual ResultValue< FSDKError, Ref< IFaceDetectionBatch > > detect(Span< const Image > images, Span< const Rect > ROIs, uint32_t perImageNum, DetectionType type=DT_BBOX) noexcept=0
Detect faces and their parameters on multiple images.
Detector type 1.
Definition: IDetector.h:38
bestDetection - the largest detection.
Definition: IDetector.h:52
virtual FaceBatchFuture redetectAsync(Span< const Image > images, IFaceDetectionBatchPtr detectionBatch, DetectionType type=DT_BBOX) const =0
Asynchronously redetect faces on multiple images. based on the detection results for the previous fra...
Get all supported parameters.
Definition: IDetector.h:63
BestDetection - detections with highest score.
Definition: IDetector.h:49
Interface of BestDetection comparer. Implement it if you want to use own BestDetection strategy...
Definition: IDetector.h:72
Addon for Result to output some value aside the result. Specialization for copiable types...
Definition: ResultValue.h:21
Image.
Definition: Image.h:38
Detector type 3 mobile version.
Definition: IDetector.h:41
virtual void setDetectionComparer(DetectionComparerType comparerType) noexcept=0
Set detection comparer from SDK defined list.
virtual ResultValue< FSDKError, Face > redetectOne(const Image &image, const Detection &detection, DetectionType type=DT_BBOX) noexcept=0
Redetect face.
ObjectDetectorClassType
Object detector type enumeration.
Definition: IDetector.h:36
DetectionType
Detection type enumeration.
Definition: IDetector.h:59
Get bounding boxes and 5 facial landmarks.
Definition: IDetector.h:61
Get bounding boxes and 68 facial landmarks.
Definition: IDetector.h:62
virtual FaceBatchFuture detectAsync(Span< const Image > images, Span< const Rect > rectangles, uint32_t perImageNum, DetectionType type=DT_BBOX) const =0
Asynchronously detect faces and their parameters on multiple images.
Detection structure. Stores a detected bounding box within a source image rect.
Definition: Detection.h:10
Span. Not owning data view. It incapsulated pointer to the continuous array with one or more T objec...
Definition: Span.h:14
bestDetection - most centered with high score.
Definition: IDetector.h:51