| Face Engine SDK 5.7.0 A face detection, recognition and tracking engine.

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 "FSDKError.h"
11 #include "IFaceDetectionBatch.h"
12 #include "IObject.h"
13 #include "Types.h"
14 #include "Types/Face.h"
15
16 #include <fsdk/vlc/future.h>
17
18 #include <functional>
19
20 namespace fsdk {
21
22 #ifndef DOXYGEN_SHOULD_SKIP_THIS
23 DECLARE_SMARTPTR(IDetector);
24 #endif
25
30 enum class SensorType {
31 Visible = 0,
32 NIR
33 };
34
44 enum ObjectDetectorClassType {
45 FACE_DET_DEFAULT = 0,
46 FACE_DET_V1 = 4,
47 FACE_DET_V2 = 5,
48 FACE_DET_V3 = 6,
49 FACE_DET_COUNT = 7,
50 };
51
55 enum DetectionComparerType {
56 DCT_CONFIDENCE = 0,
57 DCT_CENTER,
58 DCT_CENTER_AND_CONFIDENCE,
59 DCT_SIZE,
60 DCT_COUNT
61 };
62
66 enum DetectionType {
67 DT_BBOX = 0,
68 DT_LANDMARKS5 = 1<<0,
69 DT_LANDMARKS68 = 1<<1,
70 DT_ALL = 0xffff
71 };
72
73 inline DetectionType operator | (DetectionType a, DetectionType b)
74 { return static_cast<DetectionType>(static_cast<int>(a) | static_cast<int>(b)); }
75
79 class IDetectionComparer {
80 public:
81 virtual bool compare(const Image& img, const Detection& a, const Detection& b) const = 0;
82 virtual ~IDetectionComparer() = default;
83 };
84
88 class FunctionDetectionComparer : public IDetectionComparer {
89 public:
90 typedef std::function<bool(const Image& img, const Detection&, const Detection&)> Function;
91 explicit FunctionDetectionComparer(const Function& function) : func(function)
92 {}
93 bool compare(const Image& img, const Detection& a, const Detection& b) const
94 { return func(img, a, b); }
95 private:
96 Function func;
97 };
98
102 struct IDetector : IRefCounted {
115 virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>>
116 detect(
117 Span<const Image> images,
118 Span<const Rect> ROIs,
119 uint32_t perImageNum,
120 DetectionType type = DT_BBOX
121 ) noexcept = 0;
122
132 virtual ResultValue<FSDKError, Face>
133 detectOne(
134 const Image& image,
135 const Rect& rect,
136 DetectionType type = DT_BBOX) noexcept = 0;
137
154 virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>>
155 redetect(
156 Span<const Image> images,
157 Ref<IFaceDetectionBatch> detectionBatch,
158 DetectionType type = DT_BBOX
159 ) noexcept = 0;
160
176 virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>>
177 redetect(
178 Span<const Image> images,
179 Span<Span<const Detection>> detections,
180 DetectionType type = DT_BBOX
181 ) noexcept = 0;
182
192 virtual ResultValue<FSDKError, Face>
193 redetectOne(
194 const Image& image,
195 const Detection& detection,
196 DetectionType type = DT_BBOX) noexcept = 0;
197
203 virtual void setDetectionComparer(DetectionComparerType comparerType) noexcept = 0;
204
211 virtual void setCustomDetectionComparer(const IDetectionComparer* comparer) noexcept = 0;
212
226 virtual Result<FSDKError>
227 validate(
228 Span<const Image> images,
229 Span<Span<const Detection>> detections,
230 Span<Span<Result<FSDKError>>> errors) const noexcept = 0;
231
244 virtual Result<FSDKError>
245 validate(
246 Span<const Image> images,
247 Span<const Rect> rects,
248 uint32_t detectionPerImageNum,
249 Span<Result<FSDKError>> outErrors) const noexcept = 0;
250
263 virtual Result<FSDKError>
264 validate(
265 Span<const Image> images,
266 Ref<IFaceDetectionBatch> detectionBatch,
267 Span<Result<FSDKError>> outErrors) const noexcept = 0;
268
272 using FaceBatchResult = ResultValue<FSDKError, IFaceDetectionBatchPtr>;
273 using FaceBatchFuture = vlc::future<IFaceDetectionBatchPtr>;
274
290 virtual FaceBatchFuture detectAsync(
291 Span<const Image> images,
292 Span<const Rect> rectangles,
293 uint32_t perImageNum,
294 DetectionType type = DT_BBOX) const = 0;
295
315 virtual FaceBatchFuture redetectAsync(
316 Span<const Image> images,
317 IFaceDetectionBatchPtr detectionBatch,
318 DetectionType type = DT_BBOX) const = 0;
319 };
320
323 }
fsdk::IDetector::redetect
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...
fsdk::IDetector::validate
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.
fsdk::FunctionDetectionComparer
Syntax sugar, allows you to use lambdas to define a BestDetection comparer.
Definition: IDetector.h:88
fsdk::FACE_DET_V2
Detector type 2.
Definition: IDetector.h:47
DECLARE_SMARTPTR
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:59
fsdk::DCT_CENTER
BestDetection - most centered detection.
Definition: IDetector.h:57
fsdk::FACE_DET_DEFAULT
Default detector cpecified in config file.
Definition: IDetector.h:45
fsdk::Result
A structure that encapsulates an action result enumeration.
Definition: Result.h:29
Types.h
Common data types and structures.
fsdk::IDetector::setCustomDetectionComparer
virtual void setCustomDetectionComparer(const IDetectionComparer *comparer) noexcept=0
Set custom detection comparer object.
fsdk::FACE_DET_V3
Detector type 3.
Definition: IDetector.h:48
fsdk::Ref
Smart pointer for reference counted objects.
Definition: Ref.h:22
IObject.h
Object system types and interfaces.
fsdk::DT_BBOX
Get bounding boxes of faces.
Definition: IDetector.h:67
FSDKError.h
Common SDK error codes.
fsdk::DetectionComparerType
DetectionComparerType
Strategy of BestDetections comparer.
Definition: IDetector.h:55
fsdk::SensorType::NIR
NIR sensor type.
fsdk::FACE_DET_COUNT
Detector type count.
Definition: IDetector.h:49
fsdk::IDetector::detectOne
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.
fsdk::IRefCounted
Base strong reference counted object interface.
Definition: IRefCounted.h:36
fsdk::IDetector
face detector interface.
Definition: IDetector.h:102
fsdk::IDetector::detect
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.
fsdk::FACE_DET_V1
Detector type 1.
Definition: IDetector.h:46
fsdk::DCT_SIZE
bestDetection - the largest detection.
Definition: IDetector.h:59
fsdk::SensorType
SensorType
Sensor type structure. Determines which type of camera sensor is used to perform face recognition...
Definition: IDetector.h:30
fsdk::IDetector::redetectAsync
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...
fsdk::DT_ALL
Get all supported parameters.
Definition: IDetector.h:70
fsdk::DCT_CONFIDENCE
BestDetection - detections with highest score.
Definition: IDetector.h:56
fsdk::IDetectionComparer
Interface of BestDetection comparer. Implement it if you want to use own BestDetection strategy...
Definition: IDetector.h:79
fsdk::ResultValue
Addon for Result to output some value aside the result. Specialization for copiable types...
Definition: ResultValue.h:25
fsdk::SensorType::Visible
Visible sensor type.
fsdk::Image
Image.
Definition: Image.h:38
fsdk::IDetector::setDetectionComparer
virtual void setDetectionComparer(DetectionComparerType comparerType) noexcept=0
Set detection comparer from SDK defined list.
fsdk::IDetector::redetectOne
virtual ResultValue< FSDKError, Face > redetectOne(const Image &image, const Detection &detection, DetectionType type=DT_BBOX) noexcept=0
Redetect face.
fsdk::ObjectDetectorClassType
ObjectDetectorClassType
Object detector type enumeration.
Definition: IDetector.h:44
fsdk::DetectionType
DetectionType
Detection type enumeration.
Definition: IDetector.h:66
fsdk::BaseRect< int >
fsdk::DT_LANDMARKS5
Get bounding boxes and 5 facial landmarks.
Definition: IDetector.h:68
fsdk::DT_LANDMARKS68
Get bounding boxes and 68 facial landmarks.
Definition: IDetector.h:69
fsdk::IDetector::detectAsync
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.
fsdk::Detection
Detection structure. Stores a detected bounding box within a source image rect.
Definition: Detection.h:10
fsdk::Span
Span. Not owning data view. It incapsulated pointer to the continuous array with one or more T objec...
Definition: Span.h:14
fsdk::DCT_CENTER_AND_CONFIDENCE
bestDetection - most centered with high score.
Definition: IDetector.h:58