Face Engine SDK  5.17.0
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 
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         explicit FunctionDetectionComparer(const Function& function) : func(function)
00085             {}
00086         bool compare(const Image& img, const Detection& a, const Detection& b) const
00087             { return func(img, a, b); }
00088     private:
00089         Function func;
00090     };
00091 
00095     struct IDetector : IRefCounted {
00108         virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>>
00109         detect(
00110             Span<const Image> images,
00111             Span<const Rect> ROIs,
00112             uint32_t perImageNum,
00113             DetectionType type = DT_BBOX
00114         ) noexcept = 0;
00115 
00125         virtual ResultValue<FSDKError, Face>
00126         detectOne(
00127             const Image& image,
00128             const Rect& rect,
00129             DetectionType type = DT_BBOX) noexcept = 0;
00130 
00147         virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>>
00148         redetect(
00149             Span<const Image> images,
00150             Ref<IFaceDetectionBatch> detectionBatch,
00151             DetectionType type = DT_BBOX
00152         ) noexcept = 0;
00153 
00169         virtual ResultValue<FSDKError, Ref<IFaceDetectionBatch>>
00170         redetect(
00171             Span<const Image> images,
00172             Span<Span<const Detection>> detections,
00173             DetectionType type = DT_BBOX
00174         ) noexcept = 0;
00175 
00185         virtual ResultValue<FSDKError, Face>
00186         redetectOne(
00187             const Image& image,
00188             const Detection& detection,
00189             DetectionType type = DT_BBOX) noexcept = 0;
00190         
00196         virtual void setDetectionComparer(DetectionComparerType comparerType) noexcept = 0;
00197 
00204         virtual void setCustomDetectionComparer(const IDetectionComparer* comparer) noexcept = 0;
00205 
00219         virtual Result<FSDKError>
00220         validate(
00221             Span<const Image> images,
00222             Span<Span<const Detection>> detections,
00223             Span<Span<Result<FSDKError>>> errors) const noexcept = 0;
00224 
00237         virtual Result<FSDKError>
00238         validate(
00239             Span<const Image> images,
00240             Span<const Rect> rects,
00241             uint32_t detectionPerImageNum,
00242             Span<Result<FSDKError>> outErrors) const noexcept = 0;
00243         
00256         virtual Result<FSDKError>
00257         validate(
00258             Span<const Image> images,
00259             Ref<IFaceDetectionBatch> detectionBatch,
00260             Span<Result<FSDKError>> outErrors) const noexcept = 0;
00261 
00265         using FaceBatchFuture = vlc::future<IFaceDetectionBatchPtr>;
00266 
00282         virtual FaceBatchFuture detectAsync(
00283             Span<const Image> images,
00284             Span<const Rect> rectangles,
00285             uint32_t perImageNum,
00286             DetectionType type = DT_BBOX) const = 0;
00287 
00307         virtual FaceBatchFuture redetectAsync(
00308             Span<const Image> images,
00309             IFaceDetectionBatchPtr detectionBatch,
00310             DetectionType type = DT_BBOX) const = 0;
00311     };
00312 
00315 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines