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

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
36 enum ObjectDetectorClassType {
37 FACE_DET_DEFAULT = 0,
38 FACE_DET_V2 = 5,
39 FACE_DET_V3 = 6,
40 FACE_DET_V3M = 7,
41 FACE_DET_COUNT = 8,
42 };
43
47 enum DetectionComparerType {
48 DCT_CONFIDENCE = 0,
49 DCT_CENTER,
50 DCT_CENTER_AND_CONFIDENCE,
51 DCT_SIZE,
52 DCT_COUNT
53 };
54
58 enum DetectionType {
59 DT_BBOX = 0,
60 DT_LANDMARKS5 = 1 << 0,
61 DT_LANDMARKS68 = 1 << 1,
62 DT_ALL = 0xffff
63 };
64
65 inline DetectionType operator|(DetectionType a, DetectionType b) {
66 return static_cast<DetectionType>(static_cast<int>(a) | static_cast<int>(b));
67 }
68
72 class IDetectionComparer {
73 public:
74 virtual bool compare(const Image& img, const Detection& a, const Detection& b) const = 0;
75 virtual ~IDetectionComparer() = default;
76 };
77
81 class FunctionDetectionComparer : public IDetectionComparer {
82 public:
83 typedef std::function<bool(const Image& img, const Detection&, const Detection&)> Function;
84
85 explicit FunctionDetectionComparer(const Function& function)
86 : func(function) {
87 }
88
89 bool compare(const Image& img, const Detection& a, const Detection& b) const {
90 return func(img, a, b);
91 }
92
93 private:
94 Function func;
95 };
96
100 struct IDetector : IRefCounted {
113 virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>> detect(
114 Span<const Image> images,
115 Span<const Rect> ROIs,
116 uint32_t perImageNum,
117 DetectionType type = DT_BBOX) noexcept = 0;
118
128 virtual ResultValue<FSDKError, Face>
129 detectOne(const Image& image, const Rect& rect, DetectionType type = DT_BBOX) noexcept = 0;
130
147 virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>> redetect(
148 Span<const Image> images,
149 Ref<IFaceDetectionBatch> detectionBatch,
150 DetectionType type = DT_BBOX) noexcept = 0;
151
169 virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>> redetect(
170 Span<const Image> images,
171 Span<Span<const Detection>> detections,
172 DetectionType type = DT_BBOX) noexcept = 0;
173
183 virtual ResultValue<FSDKError, Face>
184 redetectOne(const Image& image, const Detection& detection, DetectionType type = DT_BBOX) noexcept = 0;
185
191 virtual void setDetectionComparer(DetectionComparerType comparerType) noexcept = 0;
192
199 virtual void setCustomDetectionComparer(const IDetectionComparer* comparer) noexcept = 0;
200
214 virtual Result<FSDKError> validate(
215 Span<const Image> images,
216 Span<Span<const Detection>> detections,
217 Span<Span<Result<FSDKError>>> errors) const noexcept = 0;
218
231 virtual Result<FSDKError> validate(
232 Span<const Image> images,
233 Span<const Rect> rects,
234 uint32_t detectionPerImageNum,
235 Span<Result<FSDKError>> outErrors) const noexcept = 0;
236
249 virtual Result<FSDKError> validate(
250 Span<const Image> images,
251 Ref<IFaceDetectionBatch> detectionBatch,
252 Span<Result<FSDKError>> outErrors) const noexcept = 0;
253
257 using FaceBatchFuture = vlc::future<IFaceDetectionBatchPtr>;
258
274 virtual FaceBatchFuture detectAsync(
275 Span<const Image> images,
276 Span<const Rect> rectangles,
277 uint32_t perImageNum,
278 DetectionType type = DT_BBOX) const = 0;
279
299 virtual FaceBatchFuture redetectAsync(
300 Span<const Image> images,
301 IFaceDetectionBatchPtr detectionBatch,
302 DetectionType type = DT_BBOX) const = 0;
303 };
304
307 } // namespace fsdk
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:81
fsdk::FACE_DET_V2
Detector type 2.
Definition: IDetector.h:38
DECLARE_SMARTPTR
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:56
fsdk
SDK namespace.
Definition: IAGSEstimator.h:8
fsdk::DCT_CENTER
BestDetection - most centered detection.
Definition: IDetector.h:49
fsdk::FACE_DET_DEFAULT
Default detector cpecified in config file.
Definition: IDetector.h:37
fsdk::Result
A structure that encapsulates an action result enumeration.
Definition: Result.h:27
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:39
fsdk::Ref
Smart pointer for reference counted objects.
Definition: Ref.h:27
IObject.h
Object system types and interfaces.
fsdk::DT_BBOX
Get bounding boxes of faces.
Definition: IDetector.h:59
FSDKError.h
Common SDK error codes.
fsdk::DetectionComparerType
DetectionComparerType
Strategy of BestDetections comparer.
Definition: IDetector.h:47
fsdk::IDetector::FaceBatchFuture
vlc::future< IFaceDetectionBatchPtr > FaceBatchFuture
Common alias for IDetector asynchronous interface.
Definition: IDetector.h:257
fsdk::FACE_DET_COUNT
Detector type count.
Definition: IDetector.h:41
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:37
fsdk::IDetector
face detector interface.
Definition: IDetector.h:100
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::DCT_SIZE
bestDetection - the largest detection.
Definition: IDetector.h:51
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:62
fsdk::DCT_CONFIDENCE
BestDetection - detections with highest score.
Definition: IDetector.h:48
fsdk::IDetectionComparer
Interface of BestDetection comparer. Implement it if you want to use own BestDetection strategy...
Definition: IDetector.h:72
fsdk::ResultValue
Addon for Result to output some value aside the result. Specialization for copiable types...
Definition: ResultValue.h:21
fsdk::Image
Image.
Definition: Image.h:38
fsdk::FACE_DET_V3M
Detector type 3 mobile version.
Definition: IDetector.h:40
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:36
fsdk::DetectionType
DetectionType
Detection type enumeration.
Definition: IDetector.h:58
fsdk::BaseRect< int >
fsdk::DT_LANDMARKS5
Get bounding boxes and 5 facial landmarks.
Definition: IDetector.h:60
fsdk::DT_LANDMARKS68
Get bounding boxes and 68 facial landmarks.
Definition: IDetector.h:61
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:50