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

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 <functional>
17
18 namespace fsdk {
19
20 #ifndef DOXYGEN_SHOULD_SKIP_THIS
21 DECLARE_SMARTPTR(IDetector);
22 #endif
23
28 enum class SensorType {
29 Visible = 0,
30 NIR
31 };
32
42 enum ObjectDetectorClassType {
43 FACE_DET_DEFAULT = 0,
44 FACE_DET_V1 = 4,
45 FACE_DET_V2 = 5,
46 FACE_DET_V3 = 6,
47 FACE_DET_COUNT = 7,
48 };
49
53 enum DetectionComparerType {
54 DCT_CONFIDENCE = 0,
55 DCT_CENTER,
56 DCT_CENTER_AND_CONFIDENCE,
57 DCT_SIZE,
58 DCT_COUNT
59 };
60
64 enum DetectionType {
65 DT_BBOX = 0,
66 DT_LANDMARKS5 = 1<<0,
67 DT_LANDMARKS68 = 1<<1,
68 DT_ALL = 0xffff
69 };
70
71 inline DetectionType operator | (DetectionType a, DetectionType b)
72 { return static_cast<DetectionType>(static_cast<int>(a) | static_cast<int>(b)); }
73
77 class IDetectionComparer {
78 public:
79 virtual bool compare(const Image& img, const Detection& a, const Detection& b) const = 0;
80 virtual ~IDetectionComparer() = default;
81 };
82
86 class FunctionDetectionComparer : public IDetectionComparer {
87 public:
88 typedef std::function<bool(const Image& img, const Detection&, const Detection&)> Function;
89 explicit FunctionDetectionComparer(const Function& function) : func(function)
90 {}
91 bool compare(const Image& img, const Detection& a, const Detection& b) const
92 { return func(img, a, b); }
93 private:
94 Function func;
95 };
96
100 struct IDetector : IRefCounted {
113 virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>>
114 detect(
115 Span<const Image> images,
116 Span<const Rect> ROIs,
117 uint32_t perImageNum,
118 DetectionType type = DT_BBOX
119 ) noexcept = 0;
120
128 virtual ResultValue<FSDKError, Face>
129 detectOne(
130 const Image& image,
131 const Rect& rect,
132 DetectionType type = DT_BBOX) noexcept = 0;
133
148 virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>>
149 redetect(
150 Span<const Image> images,
151 Ref<IFaceDetectionBatch> detectionBatch,
152 DetectionType type = DT_BBOX
153 ) noexcept = 0;
154
169 virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>>
170 redetect(
171 Span<const Image> images,
172 Span<Span<const Detection>> detections,
173 DetectionType type = DT_BBOX
174 ) noexcept = 0;
175
183 virtual ResultValue<FSDKError, Face>
184 redetectOne(
185 const Image& image,
186 const Detection& detection,
187 DetectionType type = DT_BBOX) noexcept = 0;
188
193 virtual void setDetectionComparer(DetectionComparerType comparerType) noexcept = 0;
194
200 virtual void setCustomDetectionComparer(const IDetectionComparer* comparer) noexcept = 0;
201
212 virtual Result<FSDKError>
213 validate(
214 Span<const Image> images,
215 Span<Span<const Detection>> detections,
216 Span<Span<Result<FSDKError>>> errors) const noexcept = 0;
217
227 virtual Result<FSDKError>
228 validate(
229 Span<const Image> images,
230 Span<const Rect> rects,
231 uint32_t detectionPerImageNum,
232 Span<Result<FSDKError>> outErrors) const noexcept = 0;
233
243 virtual Result<FSDKError>
244 validate(
245 Span<const Image> images,
246 Ref<IFaceDetectionBatch> detectionBatch,
247 Span<Result<FSDKError>> outErrors) const noexcept = 0;
248 };
249
252 }
fsdk::Span
Span. @detail Not owning data view. It incapsulated pointer to the continuous array with one or more ...
Definition: Span.h:15
fsdk::DT_LANDMARKS5
@ DT_LANDMARKS5
Get bounding boxes and 5 facial landmarks.
Definition: IDetector.h:66
fsdk::DT_LANDMARKS68
@ DT_LANDMARKS68
Get bounding boxes and 68 facial landmarks.
Definition: IDetector.h:67
fsdk::DT_ALL
@ DT_ALL
Get all supported parameters.
Definition: IDetector.h:68
fsdk::IDetector::redetect
virtual ResultValue< FSDKError, Ref< IFaceDetectionBatch > > redetect(Span< const Image > images, Span< Span< const Detection >> detections, DetectionType type=DT_BBOX) noexcept=0
Batched redetect faces on multiple images based on the detection results for the previous frames.
fsdk::DT_BBOX
@ DT_BBOX
Get bounding boxes of faces.
Definition: IDetector.h:65
DECLARE_SMARTPTR
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:59
fsdk::FACE_DET_COUNT
@ FACE_DET_COUNT
Detector type count.
Definition: IDetector.h:47
IObject.h
Object system types and interfaces.
fsdk::SensorType
SensorType
Sensor type structure. Determines which type of camera sensor is used to perform face recognition.
Definition: IDetector.h:28
fsdk::IDetector::validate
virtual Result< FSDKError > validate(Span< const Image > images, Ref< IFaceDetectionBatch > detectionBatch, Span< Result< FSDKError >> outErrors) const noexcept=0
Validate input of multiple frames in a single function call.
fsdk::FACE_DET_DEFAULT
@ FACE_DET_DEFAULT
Default detector cpecified in config file;.
Definition: IDetector.h:43
fsdk
SDK namespace.
Definition: IAGSEstimator.h:8
fsdk::BaseRect< int >
fsdk::FACE_DET_V1
@ FACE_DET_V1
Detector type 1.
Definition: IDetector.h:44
fsdk::IDetector::redetectOne
virtual ResultValue< FSDKError, Face > redetectOne(const Image &image, const Detection &detection, DetectionType type=DT_BBOX) noexcept=0
Redetect face.
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::DetectionComparerType
DetectionComparerType
Strategy of BestDetections comparer.
Definition: IDetector.h:53
fsdk::IDetector::setCustomDetectionComparer
virtual void setCustomDetectionComparer(const IDetectionComparer *comparer) noexcept=0
Set custom detection comparer object.
fsdk::IDetector
face detector interface.
Definition: IDetector.h:100
fsdk::DCT_CENTER
@ DCT_CENTER
BestDetection - most centered detection.
Definition: IDetector.h:55
fsdk::IDetector::setDetectionComparer
virtual void setDetectionComparer(DetectionComparerType comparerType) noexcept=0
Set detection comparer from SDK defined list.
fsdk::FACE_DET_V2
@ FACE_DET_V2
Detector type 2.
Definition: IDetector.h:45
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_V3
@ FACE_DET_V3
Detector type 3.
Definition: IDetector.h:46
fsdk::ObjectDetectorClassType
ObjectDetectorClassType
Object detector type enumeration.
Definition: IDetector.h:42
fsdk::DCT_CENTER_AND_CONFIDENCE
@ DCT_CENTER_AND_CONFIDENCE
bestDetection - most centered with high score
Definition: IDetector.h:56
fsdk::IDetector::validate
virtual Result< FSDKError > validate(Span< const Image > images, Span< const Rect > rects, uint32_t detectionPerImageNum, Span< Result< FSDKError >> outErrors) const noexcept=0
Validate input of multiple frames in a single function call.
fsdk::DetectionType
DetectionType
Detection type enumeration.
Definition: IDetector.h:64
fsdk::IDetectionComparer
Interface of BestDetection comparer. Implement it if you want to use own BestDetection strategy.
Definition: IDetector.h:77
fsdk::SensorType::Visible
@ Visible
Visible sensor type.
fsdk::DCT_SIZE
@ DCT_SIZE
bestDetection - the largest detection
Definition: IDetector.h:57
Types.h
Common data types and structures.
fsdk::Detection
Detection structure. @detail Stores a detected bounding box within a source image rect.
Definition: Detection.h:10
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::Result
A structure that encapsulates an action result enumeration.
Definition: Result.h:30
FSDKError.h
Common SDK error codes.
fsdk::FunctionDetectionComparer
Syntax sugar, allows you to use lambdas to define a BestDetection comparer.
Definition: IDetector.h:86
fsdk::Image
Image.
Definition: Image.h:37
fsdk::Ref
Smart pointer for reference counted objects.
Definition: Ref.h:22
fsdk::DCT_CONFIDENCE
@ DCT_CONFIDENCE
BestDetection - detections with highest score.
Definition: IDetector.h:54
fsdk::IRefCounted
Base strong reference counted object interface.
Definition: IRefCounted.h:36
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::ResultValue
Addon for Result to output some value aside the result. Specialization for copiable types.
Definition: ResultValue.h:21