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

IDetector.h
Go to the documentation of this file.
1
8 #pragma once
9
10 #include "IObject.h"
11 #include "Face.h"
12 #include "Human.h"
13 #include "FSDKError.h"
14 #include "Types.h"
15 #include "IResultBatch.h"
16
17 #include <functional>
18
19 namespace fsdk {
20
21 #ifndef DOXYGEN_SHOULD_SKIP_THIS
22 DECLARE_SMARTPTR(IDetector);
23 DECLARE_SMARTPTR(IHumanDetector);
24 #endif
25
30 enum RecognitionMode {
31 RM_RGB = 0,
32 RM_INFRA_RED
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_CONFIDANCE = 0,
57 DCT_CENTER,
58 DCT_CENTER_AND_CONFIDANCE,
59 DCT_SIZE,
60 DCT_COUNT
61 };
62
66 enum DetectionType {
67 dtBBox = 0,
68 dt5Landmarks = 1<<0,
69 dt68Landmarks = 1<<1,
70 dtAll = 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 enum HumanDetectionType {
80 DCT_BOX = 0,
81 DCT_POINTS = 1<<0,
82 DCT_ALL = 0xffff
83 };
84
85 inline HumanDetectionType operator | (HumanDetectionType a, HumanDetectionType b) {
86 return static_cast<HumanDetectionType>(static_cast<int>(a) | static_cast<int>(b));
87 }
88
92 class IDetectionComparer {
93 public:
94 virtual bool compare(const Image& img, const BaseDetection<float>& a, const BaseDetection<float>& b) const = 0;
95 virtual ~IDetectionComparer() = default;
96 };
97
101 class FunctionDetectionComparer : public IDetectionComparer {
102 public:
103 typedef std::function<bool(const Image& img, const BaseDetection<float>&, const BaseDetection<float>&)> Function;
104 explicit FunctionDetectionComparer(const Function& function) : func(function)
105 {}
106 bool compare(const Image& img, const BaseDetection<float>& a, const BaseDetection<float>& b) const
107 { return func(img, a, b); }
108 private:
109 Function func;
110 };
111
115 struct IDetector : IRefCounted {
126 virtual ResultValue<FSDKError, Ref<IResultBatch<Face>>> detect(
127 const Span<const Image> images,
128 const Span<const Rect> rectangles,
129 int detectionPerImageNum,
130 DetectionType type = dtBBox) noexcept = 0;
131
139 virtual ResultValue<FSDKError, Face> detectOne(
140 const Image& image,
141 const Rect& rect,
142 DetectionType type = dtBBox) noexcept = 0;
143
148 virtual void setDetectionComparer(DetectionComparerType comparerType) noexcept = 0;
149
155 virtual void setCustomDetectionComparer(const IDetectionComparer* comparer) noexcept = 0;
163 virtual ResultValue<FSDKError, bool>
164 redetectOne(
165 Face& face,
166 DetectionType type = dtBBox) noexcept = 0;
167
175 virtual fsdk::ResultValue<fsdk::FSDKError, fsdk::Face>
176 redetectOne(
177 const fsdk::Image& image,
178 const fsdk::FloatRect& rect,
179 fsdk::DetectionType type = fsdk::dtBBox) noexcept = 0;
180
193 virtual Result<FSDKError>
194 FSDK_DEPRECATED("This call is deprecated since v.3.9.3. Consider "
195 "redetect(\n"
196 "\tconst Span<Face>& faces,\n"
197 "\tDetectionType type,\n"
198 "\tconst Span<Result<FSDKError>>& outErrors) call.\n")
199 redetect(
200 const Span<Face>& faces,
201 DetectionType type = dtBBox,
202 const Span<FSDKError>* outErrors = nullptr) noexcept = 0;
203
218 virtual Result<FSDKError>
219 redetect(
220 const fsdk::Span<fsdk::Face>& faces,
221 fsdk::DetectionType type,
222 const fsdk::Span<fsdk::Result<fsdk::FSDKError>>& outErrors) noexcept = 0;
223
230 virtual fsdk::ResultValue<fsdk::FSDKError, fsdk::OrientationType>
231 estimateOrientation(const Image &image) noexcept = 0;
232 };
233
237 struct IHumanDetector : IRefCounted {
238 /*
239 * @brief Batched detect of human bodies
240 * @param images input images span; format must be R8G8B8.
241 * @param rectangles input rectangles of interest span.
242 * @param detectionPerImageNum max number of detections per input image.
243 * @return ResultValue with error code and collections of Detection objects (contains bbox and score).
244 * @note all spans should be based on user owned continuous collections.
245 * @note all spans should be equal size.
246 */
247 virtual ResultValue<FSDKError, Ref<IResultBatch<Human>>>
248 detect(
249 const Span<const Image>& image,
250 const Span<const Rect>& rect,
251 uint32_t detectionPerImageNum,
252 HumanDetectionType type = DCT_BOX) const noexcept = 0;
253
254 /*
255 * @brief redetect one person from input image;
256 * @param human fsdk::Human structure with valid image and bbox inside;
257 * @return ResultValue with ErrorCode and bool (true - if detection found);
258 * @note human structure will be overriden once redetect finish it's job.
259 **/
260 virtual ResultValue<FSDKError, bool>
261 redetectOne(Human& human) const noexcept = 0;
262
277 virtual ResultValue<FSDKError, Ref<IResultBatch<Human>>>
278 redetect(
279 Span<const Image> images,
280 Ref<IResultBatch<Human>> detectionBatch,
281 HumanDetectionType type = HumanDetectionType::DCT_BOX) const noexcept = 0;
282 };
283
286 }
fsdk::DCT_ALL
Get all supported parameters.
Definition: IDetector.h:82
fsdk::FunctionDetectionComparer
Syntax sugar, allows you to use lambdas to define a BestDetection comparer.
Definition: IDetector.h:101
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
SDK namespace.
Definition: IAGSEstimator.h:8
fsdk::DCT_CENTER
BestDetection - most centered detection.
Definition: IDetector.h:57
fsdk::IHumanDetector::redetect
virtual ResultValue< FSDKError, Ref< IResultBatch< Human > > > redetect(Span< const Image > images, Ref< IResultBatch< Human >> detectionBatch, HumanDetectionType type=HumanDetectionType::DCT_BOX) const noexcept=0
Batched redetect humans on multiple images based on the detection results for the previous frames...
fsdk::FACE_DET_DEFAULT
Default detector cpecified in config file;.
Definition: IDetector.h:45
fsdk::Result< FSDKError >
Types.h
Common data types and structures.
fsdk::IDetector::estimateOrientation
virtual fsdk::ResultValue< fsdk::FSDKError, fsdk::OrientationType > estimateOrientation(const Image &image) noexcept=0
Estimate orientation of all image (Normal, Right90deg, Left90deg or UpsideDown).
fsdk::IDetector::FSDK_DEPRECATED
virtual Result< FSDKError > FSDK_DEPRECATED("This call is deprecated since v.3.9.3. Consider " "redetect(\ "\const Span< Face > &faces,\" "\DetectionType type,\" "\const Span< Result< FSDKError >> &outErrors) call.\") redetect(const Span< Face > &faces
Batched redetect faces.
fsdk::RM_INFRA_RED
IR image processing mode.
Definition: IDetector.h:32
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:20
IObject.h
Object system types and interfaces.
fsdk::dtBBox
Get bounding boxes of faces.
Definition: IDetector.h:67
FSDKError.h
Common SDK error codes.
fsdk::Face
Definition: Face.h:9
fsdk::DetectionComparerType
DetectionComparerType
Strategy of BestDetections comparer.
Definition: IDetector.h:55
fsdk::FACE_DET_COUNT
Detector type count.
Definition: IDetector.h:49
fsdk::IRefCounted
Base strong reference counted object interface.
Definition: IRefCounted.h:36
fsdk::IHumanDetector
human body detector interface.
Definition: IDetector.h:237
fsdk::IDetector::detect
virtual ResultValue< FSDKError, Ref< IResultBatch< Face > > > detect(const Span< const Image > images, const Span< const Rect > rectangles, int detectionPerImageNum, DetectionType type=dtBBox) noexcept=0
Detect faces and landmarks on multiple images.
fsdk::IDetector
face detector interface.
Definition: IDetector.h:115
fsdk::FACE_DET_V1
Detector type 1.
Definition: IDetector.h:46
fsdk::dt68Landmarks
Get bounding boxes and 68 facial landmarks.
Definition: IDetector.h:69
fsdk::DCT_SIZE
bestDetection - the largest detection
Definition: IDetector.h:59
fsdk::dtAll
Get all supported parameters.
Definition: IDetector.h:70
fsdk::IDetectionComparer
Interface of BestDetection comparer. Implement it if you want to use own BestDetection strategy...
Definition: IDetector.h:92
fsdk::ResultValue
Addon for Result to output some value aside the result. Specialization for copiable types...
Definition: ResultValue.h:21
fsdk::DCT_POINTS
Get 17 keypoints of human, with score for each one.
Definition: IDetector.h:81
fsdk::DCT_BOX
Get bounding boxes of human bodies.
Definition: IDetector.h:80
fsdk::IDetector::detectOne
virtual ResultValue< FSDKError, Face > detectOne(const Image &image, const Rect &rect, DetectionType type=dtBBox) noexcept=0
Light function to get just one best detection from single input image.
fsdk::Human
Definition: Human.h:9
fsdk::Image
Image.
Definition: Image.h:38
fsdk::IDetector::redetectOne
virtual ResultValue< FSDKError, bool > redetectOne(Face &face, DetectionType type=dtBBox) noexcept=0
fsdk::DCT_CENTER_AND_CONFIDANCE
bestDetection - most centered with high score
Definition: IDetector.h:58
fsdk::dt5Landmarks
Get bounding boxes and 5 facial landmarks.
Definition: IDetector.h:68
fsdk::IDetector::redetect
virtual Result< FSDKError > redetect(const fsdk::Span< fsdk::Face > &faces, fsdk::DetectionType type, const fsdk::Span< fsdk::Result< fsdk::FSDKError >> &outErrors) noexcept=0
Batched redetect faces.
fsdk::IDetector::setDetectionComparer
virtual void setDetectionComparer(DetectionComparerType comparerType) noexcept=0
Set detection comparer from SDK defined list.
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::RecognitionMode
RecognitionMode
Recognition mode structure. Determines which recognition mode to use.
Definition: IDetector.h:30
fsdk::HumanDetectionType
HumanDetectionType
Human detection type enumeration.
Definition: IDetector.h:79
fsdk::DCT_CONFIDANCE
BestDetection - detections with highest score.
Definition: IDetector.h:56
fsdk::RM_RGB
RGB image processing mode.
Definition: IDetector.h:31
fsdk::IResultBatch
Definition: IResultBatch.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:13
fsdk::BaseDetection
Face detection. Stores a detected face bounding box within a source image frame as well as detection...
Definition: Detection.h:10