13#include "enrollment/Export.h"
38 class Config :
public Serializable
44 enum class Type : uint8_t
103 maxDetectionSize = value;
111 return maxDetectionSize;
122 minDetectionSize = value;
130 return minDetectionSize;
139 writer.Write(
"t",
static_cast<unsigned int>(type));
140 writer.Write(
"i", minDetectionSize);
141 writer.Write(
"x", maxDetectionSize);
173 float minDetectionSize = DefaultMinDetectionSize;
174 float maxDetectionSize = DefaultMaxDetectionSize;
175 static constexpr float DefaultMinDetectionSize = 0.05F;
176 static constexpr float DefaultMaxDetectionSize = 0.95F;
187 std::vector<std::shared_ptr<Face>>
Detect(std::shared_ptr<FaceCapture> capture)
final
189 log.LogInfo(
"Face detection for %v with cfg %v ...", capture->image, cfg);
191 auto bgr = capture->image->AsRawBGR();
192 auto r = exec->Detect(log.GetLogger(),
195 static_cast<unsigned int>(bgr.dpi),
198 cfg.GetMinDetectionSize(),
199 cfg.GetMaxDetectionSize(),
200 static_cast<unsigned int>(cfg.GetDetector()),
206 std::vector<std::shared_ptr<Face>> res;
207 for (
auto& face : r.faces)
209 if (face.item !=
nullptr)
211 const Rectangle boundingBox = { { face.roundingBox.topLeftX, face.roundingBox.topLeftY },
212 { face.roundingBox.topRightX, face.roundingBox.topRightY },
213 { face.roundingBox.bottomRightX, face.roundingBox.bottomRightY },
214 { face.roundingBox.bottomLeftX, face.roundingBox.bottomLeftY } };
215 res.emplace_back(Face::Create(capture,
216 std::shared_ptr<void>(face.item, exec->DestroyImpl()),
223 log.LogInfo(
"Face detection result %v", res);
246 , cfg(std::move(config))
259 , cfg(std::move(config))
260 , exec(std::move(executor))
274 explicit FaceDetector(std::shared_ptr<FaceExecutor> executor)
277 , exec(std::move(executor))
293 std::shared_ptr<FaceExecutor> exec;
Face detector configuration.
Definition FaceDetector.h:38
void WriteTo(Writer &writer) const final
Function serializes configuration via provided Writer.
Definition FaceDetector.h:136
Type GetDetector() const
Function gets detection type.
Definition FaceDetector.h:89
float GetMaxDetectionSize() const
Function gets max detection size.
Definition FaceDetector.h:108
Type
Type of neural network detector.
Definition FaceDetector.h:44
@ BALANCED
Neural network face detector and facial features detector with good accuracy.
Definition FaceDetector.h:56
@ ACCURATE
Neural network face detector and facial features detector with very high accuracy.
Definition FaceDetector.h:50
@ FAST
The fastest face detector in combination with the fastest face validators and facial features detecto...
Definition FaceDetector.h:64
@ ACCURATE_SERVER
Definition FaceDetector.h:75
static Config Default()
Provides default Config.
Definition FaceDetector.h:150
Config()=default
Creates Default configuration.
void SetDetector(Type value)
Function sets type of detector.
Definition FaceDetector.h:81
float GetMinDetectionSize() const
Function gets min detection size.
Definition FaceDetector.h:127
void SetMaxDetectionSize(float value)
Function sets max detection size.
Definition FaceDetector.h:100
void SetMinDetectionSize(float value)
Function sets min detection size.
Definition FaceDetector.h:119
FaceDetector implements detection by means of Innovatrics IFace.
Definition FaceDetector.h:31
FaceDetector(std::shared_ptr< FaceExecutor > executor)
Construct a new FaceDetector object Default config is used for detection.
Definition FaceDetector.h:273
FaceDetector(Config config, std::shared_ptr< FaceExecutor > executor)
Construct a new FaceDetector object.
Definition FaceDetector.h:256
FaceDetector(Config config)
Construct a new FaceDetector object GlobalFaceExecutor is used for execution of face functionality.
Definition FaceDetector.h:243
FaceDetector()
Construct a new FaceDetector object GlobalFaceExecutor is used for execution of face functionality.
Definition FaceDetector.h:231
std::vector< std::shared_ptr< Face > > Detect(std::shared_ptr< FaceCapture > capture) final
Detect faces in given image.
Definition FaceDetector.h:186
Holds instance of FaceExecutor.
Definition FaceExecutor.h:1355
Holds instance of Logger.
Definition Logger.h:275
Null argument is not allowed.
Definition EnrollmentException.h:156
It holds rectangle vertexes, width, height.
Definition ImageAttribute.h:357
Provides interface for serialization of all classes.
Definition Writer.h:164