Face Engine SDK  5.23.1
A face detection, recognition and tracking engine.
include/fsdk/IDetector.h
Go to the documentation of this file.
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_V1 = 4,      
00039         FACE_DET_V2 = 5,      
00040         FACE_DET_V3 = 6,      
00041         FACE_DET_V3M = 7,     
00042         FACE_DET_COUNT = 8,   
00043     };
00044 
00048     enum DetectionComparerType {
00049         DCT_CONFIDENCE = 0,        
00050         DCT_CENTER,                
00051         DCT_CENTER_AND_CONFIDENCE, 
00052         DCT_SIZE,                  
00053         DCT_COUNT
00054     };
00055 
00059     enum DetectionType {
00060         DT_BBOX = 0,             
00061         DT_LANDMARKS5 = 1 << 0,  
00062         DT_LANDMARKS68 = 1 << 1, 
00063         DT_ALL = 0xffff          
00064     };
00065 
00066     inline DetectionType operator|(DetectionType a, DetectionType b) {
00067         return static_cast<DetectionType>(static_cast<int>(a) | static_cast<int>(b));
00068     }
00069 
00073     class IDetectionComparer {
00074     public:
00075         virtual bool compare(const Image& img, const Detection& a, const Detection& b) const = 0;
00076         virtual ~IDetectionComparer() = default;
00077     };
00078 
00082     class FunctionDetectionComparer : public IDetectionComparer {
00083     public:
00084         typedef std::function<bool(const Image& img, const Detection&, const Detection&)> Function;
00085 
00086         explicit FunctionDetectionComparer(const Function& function)
00087             : func(function) {
00088         }
00089 
00090         bool compare(const Image& img, const Detection& a, const Detection& b) const {
00091             return func(img, a, b);
00092         }
00093 
00094     private:
00095         Function func;
00096     };
00097 
00101     struct IDetector : IRefCounted {
00114         virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>> detect(
00115             Span<const Image> images,
00116             Span<const Rect> ROIs,
00117             uint32_t perImageNum,
00118             DetectionType type = DT_BBOX) noexcept = 0;
00119 
00129         virtual ResultValue<FSDKError, Face>
00130         detectOne(const Image& image, const Rect& rect, DetectionType type = DT_BBOX) noexcept = 0;
00131 
00148         virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>> redetect(
00149             Span<const Image> images,
00150             Ref<IFaceDetectionBatch> detectionBatch,
00151             DetectionType type = DT_BBOX) noexcept = 0;
00152 
00170         virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>> redetect(
00171             Span<const Image> images,
00172             Span<Span<const Detection>> detections,
00173             DetectionType type = DT_BBOX) noexcept = 0;
00174 
00184         virtual ResultValue<FSDKError, Face>
00185         redetectOne(const Image& image, const Detection& detection, DetectionType type = DT_BBOX) noexcept = 0;
00186 
00192         virtual void setDetectionComparer(DetectionComparerType comparerType) noexcept = 0;
00193 
00200         virtual void setCustomDetectionComparer(const IDetectionComparer* comparer) noexcept = 0;
00201 
00215         virtual Result<FSDKError> validate(
00216             Span<const Image> images,
00217             Span<Span<const Detection>> detections,
00218             Span<Span<Result<FSDKError>>> errors) const noexcept = 0;
00219 
00232         virtual Result<FSDKError> validate(
00233             Span<const Image> images,
00234             Span<const Rect> rects,
00235             uint32_t detectionPerImageNum,
00236             Span<Result<FSDKError>> outErrors) const noexcept = 0;
00237 
00250         virtual Result<FSDKError> validate(
00251             Span<const Image> images,
00252             Ref<IFaceDetectionBatch> detectionBatch,
00253             Span<Result<FSDKError>> outErrors) const noexcept = 0;
00254 
00258         using FaceBatchFuture = vlc::future<IFaceDetectionBatchPtr>;
00259 
00275         virtual FaceBatchFuture detectAsync(
00276             Span<const Image> images,
00277             Span<const Rect> rectangles,
00278             uint32_t perImageNum,
00279             DetectionType type = DT_BBOX) const = 0;
00280 
00300         virtual FaceBatchFuture redetectAsync(
00301             Span<const Image> images,
00302             IFaceDetectionBatchPtr detectionBatch,
00303             DetectionType type = DT_BBOX) const = 0;
00304     };
00305 
00308 } // namespace fsdk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines