Face Engine SDK  4.7.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 
31  RM_RGB = 0,
33  };
34 
50  };
51 
60  DCT_COUNT
61  };
62 
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 
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 
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 
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 
127  const Span<const Image> images,
128  const Span<const Rect> rectangles,
129  int detectionPerImageNum,
130  DetectionType type = dtBBox) noexcept = 0;
131 
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;
165  Face& face,
166  DetectionType type = dtBBox) noexcept = 0;
167 
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>
220  const fsdk::Span<fsdk::Face>& faces,
221  fsdk::DetectionType type,
222  const fsdk::Span<fsdk::Result<fsdk::FSDKError>>& outErrors) noexcept = 0;
223 
231  estimateOrientation(const Image &image) noexcept = 0;
232  };
233 
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  */
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  **/
261  redetectOne(Human& human) const noexcept = 0;
262 
279  Span<const Image> images,
280  Ref<IResultBatch<Human>> detectionBatch,
281  HumanDetectionType type = HumanDetectionType::DCT_BOX) const noexcept = 0;
282  };
283 
286 }
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::Span
Span. @detail Not owning data view. It incapsulated pointer to the continuous array with one or more ...
Definition: Span.h:14
fsdk::DCT_CONFIDANCE
@ DCT_CONFIDANCE
BestDetection - detections with highest score.
Definition: IDetector.h:56
fsdk::FSDKError
FSDKError
Common SDK error codes.
Definition: FSDKError.h:17
DECLARE_SMARTPTR
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:59
fsdk::dtBBox
@ dtBBox
Get bounding boxes of faces.
Definition: IDetector.h:67
fsdk::dtAll
@ dtAll
Get all supported parameters.
Definition: IDetector.h:70
fsdk::DCT_POINTS
@ DCT_POINTS
Get 17 keypoints of human, with score for each one.
Definition: IDetector.h:81
fsdk::Face
Definition: Face.h:9
fsdk::FACE_DET_COUNT
@ FACE_DET_COUNT
Detector type count.
Definition: IDetector.h:49
IObject.h
Object system types and interfaces.
fsdk::dt5Landmarks
@ dt5Landmarks
Get bounding boxes and 5 facial landmarks.
Definition: IDetector.h:68
fsdk::FACE_DET_DEFAULT
@ FACE_DET_DEFAULT
Default detector cpecified in config file;.
Definition: IDetector.h:45
fsdk
SDK namespace.
Definition: IAGSEstimator.h:8
fsdk::BaseRect< int >
fsdk::FACE_DET_V1
@ FACE_DET_V1
Detector type 1.
Definition: IDetector.h:46
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::DetectionComparerType
DetectionComparerType
Strategy of BestDetections comparer.
Definition: IDetector.h:55
fsdk::IDetector::setCustomDetectionComparer
virtual void setCustomDetectionComparer(const IDetectionComparer *comparer) noexcept=0
Set custom detection comparer object.
fsdk::RM_INFRA_RED
@ RM_INFRA_RED
IR image processing mode.
Definition: IDetector.h:32
fsdk::IDetector
face detector interface.
Definition: IDetector.h:115
fsdk::IDetector::redetectOne
virtual fsdk::ResultValue< fsdk::FSDKError, fsdk::Face > redetectOne(const fsdk::Image &image, const fsdk::FloatRect &rect, fsdk::DetectionType type=fsdk::dtBBox) noexcept=0
Redetect face.
fsdk::DCT_CENTER
@ DCT_CENTER
BestDetection - most centered detection.
Definition: IDetector.h:57
fsdk::DCT_BOX
@ DCT_BOX
Get bounding boxes of human bodies.
Definition: IDetector.h:80
fsdk::DCT_CENTER_AND_CONFIDANCE
@ DCT_CENTER_AND_CONFIDANCE
bestDetection - most centered with high score
Definition: IDetector.h:58
fsdk::IDetector::setDetectionComparer
virtual void setDetectionComparer(DetectionComparerType comparerType) noexcept=0
Set detection comparer from SDK defined list.
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::FACE_DET_V2
@ FACE_DET_V2
Detector type 2.
Definition: IDetector.h:47
fsdk::IHumanDetector
human body detector interface.
Definition: IDetector.h:237
fsdk::FACE_DET_V3
@ FACE_DET_V3
Detector type 3.
Definition: IDetector.h:48
fsdk::ObjectDetectorClassType
ObjectDetectorClassType
Object detector type enumeration.
Definition: IDetector.h:44
fsdk::DetectionType
DetectionType
Detection type enumeration.
Definition: IDetector.h:66
fsdk::IDetectionComparer
Interface of BestDetection comparer. Implement it if you want to use own BestDetection strategy.
Definition: IDetector.h:92
fsdk::Human
Definition: Human.h:9
fsdk::IDetector::redetectOne
virtual ResultValue< FSDKError, bool > redetectOne(Face &face, DetectionType type=dtBBox) noexcept=0
fsdk::RecognitionMode
RecognitionMode
Recognition mode structure. Determines which recognition mode to use.
Definition: IDetector.h:30
fsdk::dt68Landmarks
@ dt68Landmarks
Get bounding boxes and 68 facial landmarks.
Definition: IDetector.h:69
fsdk::DCT_SIZE
@ DCT_SIZE
bestDetection - the largest detection
Definition: IDetector.h:59
Types.h
Common data types and structures.
fsdk::DCT_ALL
@ DCT_ALL
Get all supported parameters.
Definition: IDetector.h:82
fsdk::IResultBatch
Definition: IResultBatch.h:10
fsdk::Result< FSDKError >
FSDKError.h
Common SDK error codes.
fsdk::FunctionDetectionComparer
Syntax sugar, allows you to use lambdas to define a BestDetection comparer.
Definition: IDetector.h:101
fsdk::OrientationType
OrientationType
Estimation of image orientation.
Definition: OrientationType.h:10
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::Image
Image.
Definition: Image.h:38
fsdk::Ref
Smart pointer for reference counted objects.
Definition: Ref.h:20
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::IDetector::FSDK_DEPRECATED
virtual Result< FSDKError > FSDK_DEPRECATED("This call is deprecated since v.3.9.3. Consider " "redetect(\n" "\tconst Span<Face>& faces,\n" "\tDetectionType type,\n" "\tconst Span<Result<FSDKError>>& outErrors) call.\n") redetect(const Span< Face > &faces
Batched redetect faces.
fsdk::IRefCounted
Base strong reference counted object interface.
Definition: IRefCounted.h:36
fsdk::BaseDetection
Face detection. @detail Stores a detected face bounding box within a source image frame as well as de...
Definition: Detection.h:10
fsdk::HumanDetectionType
HumanDetectionType
Human detection type enumeration.
Definition: IDetector.h:79
fsdk::RM_RGB
@ RM_RGB
RGB image processing mode.
Definition: IDetector.h:31
fsdk::ResultValue
Addon for Result to output some value aside the result. Specialization for copiable types.
Definition: ResultValue.h:21