Face Engine SDK
5.25.0
A face detection, recognition and tracking engine.
|
00001 00008 #pragma once 00009 00010 #include <fsdk/FSDKError.h> 00011 #include <fsdk/IFaceDetectionBatch.h> 00012 #include <fsdk/IObject.h> 00013 #include <fsdk/Types.h> 00014 #include <fsdk/Types/Face.h> 00015 #include <fsdk/Types/SensorType.h> 00016 00017 #include <fsdk/vlc/future.h> 00018 00019 #include <functional> 00020 00021 namespace fsdk { 00022 00023 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00024 DECLARE_SMARTPTR(IDetector); 00025 #endif 00026 00036 enum ObjectDetectorClassType { 00037 FACE_DET_DEFAULT = 0, 00038 FACE_DET_V2 = 5, 00039 FACE_DET_V3 = 6, 00040 FACE_DET_V3M = 7, 00041 FACE_DET_COUNT = 8, 00042 }; 00043 00047 enum DetectionComparerType { 00048 DCT_CONFIDENCE = 0, 00049 DCT_CENTER, 00050 DCT_CENTER_AND_CONFIDENCE, 00051 DCT_SIZE, 00052 DCT_COUNT 00053 }; 00054 00058 enum DetectionType { 00059 DT_BBOX = 0, 00060 DT_LANDMARKS5 = 1 << 0, 00061 DT_LANDMARKS68 = 1 << 1, 00062 DT_ALL = 0xffff 00063 }; 00064 00065 inline DetectionType operator|(DetectionType a, DetectionType b) { 00066 return static_cast<DetectionType>(static_cast<int>(a) | static_cast<int>(b)); 00067 } 00068 00072 class IDetectionComparer { 00073 public: 00074 virtual bool compare(const Image& img, const Detection& a, const Detection& b) const = 0; 00075 virtual ~IDetectionComparer() = default; 00076 }; 00077 00081 class FunctionDetectionComparer : public IDetectionComparer { 00082 public: 00083 typedef std::function<bool(const Image& img, const Detection&, const Detection&)> Function; 00084 00085 explicit FunctionDetectionComparer(const Function& function) 00086 : func(function) { 00087 } 00088 00089 bool compare(const Image& img, const Detection& a, const Detection& b) const { 00090 return func(img, a, b); 00091 } 00092 00093 private: 00094 Function func; 00095 }; 00096 00100 struct IDetector : IRefCounted { 00113 virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>> detect( 00114 Span<const Image> images, 00115 Span<const Rect> ROIs, 00116 uint32_t perImageNum, 00117 DetectionType type = DT_BBOX) noexcept = 0; 00118 00128 virtual ResultValue<FSDKError, Face> 00129 detectOne(const Image& image, const Rect& rect, DetectionType type = DT_BBOX) noexcept = 0; 00130 00147 virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>> redetect( 00148 Span<const Image> images, 00149 Ref<IFaceDetectionBatch> detectionBatch, 00150 DetectionType type = DT_BBOX) noexcept = 0; 00151 00169 virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>> redetect( 00170 Span<const Image> images, 00171 Span<Span<const Detection>> detections, 00172 DetectionType type = DT_BBOX) noexcept = 0; 00173 00183 virtual ResultValue<FSDKError, Face> 00184 redetectOne(const Image& image, const Detection& detection, DetectionType type = DT_BBOX) noexcept = 0; 00185 00191 virtual void setDetectionComparer(DetectionComparerType comparerType) noexcept = 0; 00192 00199 virtual void setCustomDetectionComparer(const IDetectionComparer* comparer) noexcept = 0; 00200 00214 virtual Result<FSDKError> validate( 00215 Span<const Image> images, 00216 Span<Span<const Detection>> detections, 00217 Span<Span<Result<FSDKError>>> errors) const noexcept = 0; 00218 00231 virtual Result<FSDKError> validate( 00232 Span<const Image> images, 00233 Span<const Rect> rects, 00234 uint32_t detectionPerImageNum, 00235 Span<Result<FSDKError>> outErrors) const noexcept = 0; 00236 00249 virtual Result<FSDKError> validate( 00250 Span<const Image> images, 00251 Ref<IFaceDetectionBatch> detectionBatch, 00252 Span<Result<FSDKError>> outErrors) const noexcept = 0; 00253 00257 using FaceBatchFuture = vlc::future<IFaceDetectionBatchPtr>; 00258 00274 virtual FaceBatchFuture detectAsync( 00275 Span<const Image> images, 00276 Span<const Rect> rectangles, 00277 uint32_t perImageNum, 00278 DetectionType type = DT_BBOX) const = 0; 00279 00299 virtual FaceBatchFuture redetectAsync( 00300 Span<const Image> images, 00301 IFaceDetectionBatchPtr detectionBatch, 00302 DetectionType type = DT_BBOX) const = 0; 00303 }; 00304 00307 } // namespace fsdk