PFaceLog6Parameters.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2016 Digital Barriers plc. All rights reserved.
3  * Contact: http://www.digitalbarriers.com/
4  *
5  * This file is part of the Papillon SDK.
6  *
7  * You can't use, modify or distribute any part of this file without
8  * the explicit written agreements of Digital Barriers.
9  */
10 
15 #pragma once
16 #include <PAnalytics.h>
17 #include <PMath.h>
18 #include <PProperties.h>
19 #include <PWatchlist.h>
20 #include <PWatchlistOptions.h>
21 #include <PRectanglei.h>
22 #include "PResult.h"
23 
24 PAPILLON_BEGIN_NAMESPACE
25 /* Full list of parameters
26  * FaceDetector - PDetector object to be used as face detector. If not set a new detector will be created.
27  * Detector - detectorName name of the face detector to be created if no FaceDetector object has been passed.
28  * Defaults to FaceDetector6
29  * faceDetector.???? - parameters for the new face detector if no FaceDetector object has been passed
30  * MaxFaceDetectorFR (8) - maximum number of frames to process per second. Use -1 to disable.
31  *
32  * gpuId (-1) - default GPU to use, (-2=IntelGPU -1=CPU, 0=1st GPU, 1=2nd GPU, etc.)
33 
34  * FaceRecognitionDescriber - PDescriber object to be used for face recognition and tracking.
35  * If not set default (FaceFast) will be created.
36  * describerBatchSize (4) - use this batch size if a new face recognition decriber was created
37  *
38  * Watchlist - PWatchlist object to use
39  * WatchlistOptions PWatchlistOptions object (only used if PWatchlist is set)
40  * Comparer - PComparer object (only used if PWatchlist is set)
41  *
42  * MetaDescribers - Plist of PDescriber objects. Used to add metadata descriptions to detections.
43  * By Default Gender and Mask classifiers will be used. Supply empty list to disable all describers.
44  *
45  * MaxGap (10) - max gap in sighting to stop it
46  * MinLength (3) - min length of sighting in detections
47  * MaxLength (100) - max length of sighting in detections (not in frames) (note the difference (there might be frames with no detections))
48  */
49 
58 #define DEFAULT_FACE_DETECTOR "FaceDetector6"
59 #define DEFAULT_FACE_DETECTOR_GPU_ID -1
60 #define DEFAULT_MIN_DETECTION_SIZE 60
61 #define DEFAULT_MAX_DETECTION_SIZE 1000
62 #define DEFAULT_FACE_DETECTOR_THRESHOLD 0.7
63 #define DEFAULT_ENABLE_LOCALISER true
64 #define DEFAULT_TRACKER "FrameToFrameKalmanTracker"
65 #define DEFAULT_TRACKER_THRESHOLD 0.0
66 #define DEFAULT_MAX_LENGTH 100
67 #define DEFAULT_MIN_LENGTH 3
68 #define DEFAULT_MAX_GAP 25
69 #define DEFAULT_GENDER_DETECTION true
70 #define DEFAULT_GENDER_DETECTION_THRESHOLD 0.0
71 #define DEFAULT_MASK_DETECTION true
72 #define DEFAULT_MASK_DETECTION_THRESHOLD 0.0f
73 #define DEFAULT_FACE_RECOGNITION_MODEL "Face"
74 #define DEFAULT_FACE_RECOGNITION false
75 #define DEFAULT_FACE_RECOGNITION_THRESHOLD 0.55f
76 #define DEFAULT_MAX_FRAME_RATE 8
77 #define DEFAULT_GPU_ID -1
78 
82 class PFaceLog6Parameters : public papillon::PProperties {
83 
84  public:
89  PFaceLog6Parameters(const papillon::PString& parametersPrefix = papillon::PString())
90  : papillon::PProperties()
91  , m_parametersPrefix{parametersPrefix} {}
92 
96  PFaceLog6Parameters(const papillon::PProperties& properties, const papillon::PString& parametersPrefix)
97  : papillon::PProperties{properties.Clone()}
98  , m_parametersPrefix{parametersPrefix} {}
99 
103  virtual ~PFaceLog6Parameters() {}
104 
108  PAPILLON_DEPRECATED("This function will be removed in Papillon 5")
109  static PFaceLog6Parameters BuildDefaultParameters(const papillon::PString& parametersPrefix = papillon::PString()) {
110  PFaceLog6Parameters parameters(parametersPrefix);
111  return parameters;
112  }
113 
119  static PFaceLog6Parameters FromAnalytics(const papillon::PAnalytics& analytics) {
120  if(analytics.GetPluginName() != "PAnalyticsFaceLog6")
121  return PFaceLog6Parameters();
122 
123  PProperties analyticsParameters;
124  if(analytics.Get("parameters", analyticsParameters).Failed())
125  return PFaceLog6Parameters();
126 
127  PFaceLog6Parameters parameters = static_cast<const PFaceLog6Parameters&>(analyticsParameters);
128  return parameters;
129  }
130 
131  static papillon::PString GetFaceDetectorParametersPrefix() {
132  static papillon::PString prefix("faceDetector.");
133  return prefix;
134  }
135 
136 
140  void SetFaceDetector(papillon::PString& faceDetector) {
141  Set(m_parametersPrefix + "FaceDetectorName", faceDetector);
142  }
143 
147  papillon::PString GetFaceDetector() const {
148  papillon::PString faceDetector = DEFAULT_FACE_DETECTOR;
149  Get(m_parametersPrefix + "FaceDetectorName", faceDetector);
150  return faceDetector;
151  }
152 
156  void SetFaceDetectorGpuId(papillon::int32 faceDetectorGpuId) {
157  Set(m_parametersPrefix + GetFaceDetectorParametersPrefix() + "gpuId", faceDetectorGpuId);
158  }
159 
163  papillon::int32 GetFaceDetectorGpuId() const {
164  papillon::int32 faceDetectorGpuId = DEFAULT_FACE_DETECTOR_GPU_ID;
165  Get(m_parametersPrefix + GetFaceDetectorParametersPrefix() + "gpuId", faceDetectorGpuId);
166  return faceDetectorGpuId;
167  }
168 
173  void SetMinDetectionSize(papillon::int32 minDetectionSize) {
174  Set(m_parametersPrefix + GetFaceDetectorParametersPrefix() + "MinDetectionSize", minDetectionSize);
175  }
176 
180  papillon::int32 GetMinDetectionSize() const {
181  papillon::int32 minDetectionSize = DEFAULT_MIN_DETECTION_SIZE;
182  Get(m_parametersPrefix + GetFaceDetectorParametersPrefix() + "MinDetectionSize", minDetectionSize);
183  return minDetectionSize;
184  }
185 
190  void SetMaxDetectionSize(papillon::int32 maxDetectionSize) {
191  Set(m_parametersPrefix + GetFaceDetectorParametersPrefix() + "MaxDetectionSize", maxDetectionSize);
192  }
193 
198  papillon::int32 GetMaxDetectionSize() const {
199  papillon::int32 maxDetectionSize = DEFAULT_MAX_DETECTION_SIZE;
200  Get(m_parametersPrefix + GetFaceDetectorParametersPrefix() + "MaxDetectionSize", maxDetectionSize);
201  return maxDetectionSize;
202  }
203 
208  void SetFaceDetectorThreshold(double faceDetectorThreshold) {
209  Set(m_parametersPrefix + GetFaceDetectorParametersPrefix() + "Threshold", faceDetectorThreshold);
210  }
211 
215  double GetFaceDetectorThreshold() const {
216  double faceDetectorThreshold = DEFAULT_FACE_DETECTOR_THRESHOLD;
217  Get(m_parametersPrefix + GetFaceDetectorParametersPrefix() + "Threshold", faceDetectorThreshold);
218  return faceDetectorThreshold;
219  }
220 
224  void SetRoi(const papillon::PRectanglei& roi) { Set(m_parametersPrefix + GetFaceDetectorParametersPrefix() + "regionOfInterest", roi); }
225 
229  papillon::PRectanglei GetRoi() const {
230  papillon::PRectanglei roi(0, 0, 0, 0);
231  Get(m_parametersPrefix + GetFaceDetectorParametersPrefix() + "regionOfInterest", roi);
232  return roi;
233  }
234 
238  void SetMaskDetection(bool maskDetection) { Set(m_parametersPrefix + "MaskDetection", maskDetection); }
239 
243  bool GetMaskDetection() const {
244  bool maskDetection = DEFAULT_MASK_DETECTION;
245  Get(m_parametersPrefix + "MaskDetection", maskDetection);
246  return maskDetection;
247  }
248 
252  void SetMaskDetectionThreshold(float maskDetectionThreshold) { Set(m_parametersPrefix + "MaskDetectionThreshold", maskDetectionThreshold); }
253 
258  float maskDetectionThreshold = DEFAULT_MASK_DETECTION_THRESHOLD;
259  Get(m_parametersPrefix + "MaskDetectionThreshold", maskDetectionThreshold);
260  return maskDetectionThreshold;
261  }
262 
266  void SetGenderDetection(bool genderDetection) { Set(m_parametersPrefix + "GenderDetection", genderDetection); }
267 
271  bool GetGenderDetection() const {
272  bool genderDetection = DEFAULT_GENDER_DETECTION;
273  Get(m_parametersPrefix + "GenderDetection", genderDetection);
274  return genderDetection;
275  }
276 
280  void SetGenderDetectionThreshold(float genderDetectionThreshold) { Set(m_parametersPrefix + "GenderDetectionThreshold", genderDetectionThreshold); }
281 
286  float genderDetectionThreshold = DEFAULT_GENDER_DETECTION_THRESHOLD;
287  Get(m_parametersPrefix + "GenderDetectionThreshold", genderDetectionThreshold);
288  return genderDetectionThreshold;
289  }
290 
294  void SetFaceRecognition(bool faceRecognition) { Set(m_parametersPrefix + "FaceRecognition", faceRecognition); }
295 
299  bool GetFaceRecognition() const {
300  bool faceRecognition = DEFAULT_FACE_RECOGNITION;
301  Get(m_parametersPrefix + "FaceRecognition", faceRecognition);
302  return faceRecognition;
303  }
304 
308  void SetFaceRecognitionModel(const papillon::PString & faceRecognitionModel) { Set(m_parametersPrefix + "FaceRecognitionModel", faceRecognitionModel); }
309 
313  papillon::PString GetFaceRecognitionModel() const {
314  papillon::PString faceRecognitionModel = DEFAULT_FACE_RECOGNITION_MODEL;
315  Get(m_parametersPrefix + "FaceRecognitionModel", faceRecognitionModel);
316  return faceRecognitionModel;
317  }
318 
322  void SetWatchlist(const papillon::PWatchlist& watchlist) { Set(m_parametersPrefix + "Watchlist", watchlist); }
323 
327  papillon::PWatchlist GetWatchlist() const {
328  papillon::PWatchlist watchlist;
329  Get(m_parametersPrefix + "Watchlist", watchlist);
330  return watchlist;
331  }
332 
336  void SetWatchlistOptions(const papillon::PWatchlistOptions& watchlistOptions) {
337  Set(m_parametersPrefix + "WatchlistOptions", watchlistOptions);
338  }
339 
343  papillon::PWatchlistOptions GetWatchlistOptions() const {
344  papillon::PWatchlistOptions watchlistOptions(DEFAULT_FACE_RECOGNITION_THRESHOLD, 1, false, PProperties());
345  Get(m_parametersPrefix + "WatchlistOptions", watchlistOptions);
346  return watchlistOptions;
347  }
348 
352  void SetTracker(const PString & tracker) { Set(m_parametersPrefix + "Tracker", tracker); }
353 
357  PString GetTracker() const {
358  PString tracker = DEFAULT_TRACKER;
359  Get(m_parametersPrefix + "Tracker", tracker);
360  return tracker;
361  }
362 
366  void SetTrackerThreshold(float trackerThreshold) { Set(m_parametersPrefix + "TrackerThreshold", trackerThreshold); }
367 
371  float GetTrackerThreshold() const {
372  float trackerThreshold = DEFAULT_TRACKER_THRESHOLD;
373  Get(m_parametersPrefix + "TrackerThreshold", trackerThreshold);
374  return trackerThreshold;
375  }
376 
377 
381  void SetMaxLength(papillon::int32 maxLength) {
382  Set(m_parametersPrefix + "MaxLength", maxLength);
383  }
384 
388  papillon::int32 GetMaxLength() const {
389  papillon::int32 v = DEFAULT_MAX_LENGTH;
390  Get(m_parametersPrefix + "MaxLength", v);
391  return v;
392  }
393 
397  void SetMinLength(papillon::int32 minLength) {
398  Set(m_parametersPrefix + "MinLength", minLength);
399  }
400 
404  papillon::int32 GetMinLength() const {
405  papillon::int32 v = DEFAULT_MIN_LENGTH;
406  Get(m_parametersPrefix + "MinLength", v);
407  return v;
408  }
409 
413  void SetMaxGap(papillon::int32 v) {
414  Set(m_parametersPrefix + "MaxGap", v);
415  }
416 
420  papillon::int32 GetMaxGap() const {
421  papillon::int32 v = DEFAULT_MAX_GAP;
422  Get(m_parametersPrefix + "MaxGap", v);
423  return v;
424  }
425 
426 
430  PAPILLON_DEPRECATED("This will be removed in Papillon 5.0")
431  void SetSightingSimilarity(double threshold) { Set(m_parametersPrefix + "SightingSimilarity", threshold); }
432 
437  PAPILLON_DEPRECATED("This will be removed in Papillon 5.0")
438  double GetSightingSimilarity() const {
439  double threshold = papillon::PMath::NaNd();
440  Get(m_parametersPrefix + "SightingSimilarity", threshold);
441  return threshold;
442  }
443 
450  void SetMaxFaceDetectorFR(double frameRate) { Set(m_parametersPrefix + "MaxFaceDetectorFR", frameRate); }
451 
455  double GetMaxFaceDetectorFR() const {
456  double frameRate = DEFAULT_MAX_FRAME_RATE;
457  Get(m_parametersPrefix + "MaxFaceDetectorFR", frameRate);
458  return frameRate;
459  }
460 
464  void SetGpuId(papillon::int32 gpuId) {
465  Set(m_parametersPrefix + "gpuId", gpuId);
466  }
467 
471  papillon::int32 GetGpuId() const {
472  papillon::int32 v = DEFAULT_GPU_ID;
473  Get(m_parametersPrefix + "gpuId", v);
474  return v;
475  }
476 
477  const papillon::PString& GetParametersPrefix() const { return m_parametersPrefix; }
478 
479  protected:
480  papillon::PString m_parametersPrefix;
481 };
482 
483 PAPILLON_END_NAMESPACE
PFaceLog6Parameters(const papillon::PProperties &properties, const papillon::PString &parametersPrefix)
Constructs an parameters with prefix.
#define DEFAULT_FACE_DETECTOR_THRESHOLD
virtual ~PFaceLog6Parameters()
Destroys this object.
Configuration class for PFaceLog6.
#define DEFAULT_GENDER_DETECTION_THRESHOLD
void SetSightingSimilarity(double threshold)
Deprecated: Sets the recognition threshold to use when considering to join two tracks together...
void SetMaxDetectionSize(papillon::int32 maxDetectionSize)
Sets the maximum detection size in pixels for a face (face detector parameter).
papillon::int32 GetMinDetectionSize() const
Returns the minimum detection size in pixels for a face (face detector parameter).
papillon::PString GetFaceDetector() const
Get the name of the face-detector we are using.
Class PWatchlistOptions: holds common watchlist options.
Class PRectanglei: an axis-aligned rectangle with 32-bit int coordinates.
#define DEFAULT_MASK_DETECTION_THRESHOLD
void SetMaxGap(papillon::int32 v)
Sets maximum number of frames in with no detections to stop track.
void SetGenderDetectionThreshold(float genderDetectionThreshold)
Set threshold to use for gender-detector.
papillon::int32 GetMaxLength() const
Returns the mmaximum number of detections allowed in a single sighting.
The PString class provides an Unicode character strings.
Definition: PString.h:37
papillon::int32 GetFaceDetectorGpuId() const
Returns the minimum detection size in pixels for a face (face detector parameter) or -1 if this param...
void SetFaceRecognitionModel(const papillon::PString &faceRecognitionModel)
Perform face-recognition when running FaceLog6.
const papillon::PString & GetParametersPrefix() const
bool GetFaceRecognition() const
Returns status on whether face-recognition is being performed.
papillon::PString GetFaceRecognitionModel() const
Returns status on whether face-recognition is being performed.
double GetMaxFaceDetectorFR() const
Returns the Maximum Face Detector FR parameter.
void SetRoi(const papillon::PRectanglei &roi)
Sets region of interest.
#define DEFAULT_FACE_RECOGNITION_MODEL
void SetGpuId(papillon::int32 gpuId)
Sets the GPU to use for the meta-classifiers and face-recognition describers.
Class PAnalytics: parent class for all video analytics algorithms which analyse a video stream and re...
Class PProperties: a container of generic properties indexed by their name.
#define DEFAULT_TRACKER
void SetWatchlist(const papillon::PWatchlist &watchlist)
Sets the watchlist of identities.
float GetMaskDetectionThreshold() const
Returns threshold to use for mask-detector.
The PProperties class represents a container of properties; each property has a name (PString) and a ...
Definition: PProperties.h:38
papillon::int32 GetMaxGap() const
Returns maximum number of frames in with no detections to stop track (-1 - is error) ...
#define DEFAULT_MAX_DETECTION_SIZE
#define DEFAULT_MIN_LENGTH
void SetFaceDetector(papillon::PString &faceDetector)
Set the face-detector we are using by product name, e.g.
#define DEFAULT_MAX_LENGTH
papillon::PString m_parametersPrefix
PProperties Clone() const
Returns a shallow copy of this object (only the container is cloned, not contained objects)...
void SetMaxFaceDetectorFR(double frameRate)
Sets the Maximum Face Detector FR: maximum rate for feeding frames to the face detector.
#define DEFAULT_TRACKER_THRESHOLD
papillon::int32 GetGpuId() const
Returns the GPU used for the meta-classifiers and face-recognition describers.
papillon::int32 GetMinLength() const
Returns the minimum number of detections required to create sighting event.
void SetTrackerThreshold(float trackerThreshold)
Set threshold to use for tracker.
void SetFaceDetectorThreshold(double faceDetectorThreshold)
Sets the face detector threshold.
#define DEFAULT_FACE_DETECTOR
The PFaceLog6Parameters is an helper class to configure FaceLog6 PAnalytics plugin.
PString GetTracker() const
Returns the name of the tracker that is currently being used.
#define DEFAULT_MIN_DETECTION_SIZE
bool GetGenderDetection() const
Returns status on whether gender detection is being performed.
void SetGenderDetection(bool genderDetection)
Perform gender-detection when running FaceLog6.
#define DEFAULT_MASK_DETECTION
void SetMaxLength(papillon::int32 maxLength)
Sets the maximum number of detections in sightings for it to be reported.
void SetWatchlistOptions(const papillon::PWatchlistOptions &watchlistOptions)
Sets the watchlist options.
void SetMaskDetectionThreshold(float maskDetectionThreshold)
Set threshold to use for mask-detector.
void SetMinLength(papillon::int32 minLength)
Sets the minimum number of detections for a sighting event to be raised.
papillon::PWatchlist GetWatchlist() const
Returns the watchlist parameters or an empty watchlist if this parameter is not available.
void SetFaceDetectorGpuId(papillon::int32 faceDetectorGpuId)
Set the GPU-ID for the face-detector to use.
papillon::PRectanglei GetRoi() const
Returns region of interest.
double GetFaceDetectorThreshold() const
Returns the threshold parameter for the face detector.
Class PResult: a result returned by most of Papillon functions; this class is used to replace classic...
#define DEFAULT_FACE_RECOGNITION_THRESHOLD
Math toolbox.
#define DEFAULT_GPU_ID
static PFaceLog6Parameters FromAnalytics(const papillon::PAnalytics &analytics)
Retrieves parameters from a FaceLog6 analytics instance.
float GetGenderDetectionThreshold() const
Returns threshold to use for gender-detector.
papillon::int32 GetMaxDetectionSize() const
Returns the maximum detection size in pixels for a face (face detector parameter) or -1 if this param...
papillon::PWatchlistOptions GetWatchlistOptions() const
Returns the watchlist options parameters or a default PWatchlistOption object if this parameter is no...
#define DEFAULT_FACE_DETECTOR_GPU_ID
float GetTrackerThreshold() const
Returns threshold to use for tracker.
void SetTracker(const PString &tracker)
Set tracker to use.
#define DEFAULT_MAX_GAP
bool GetMaskDetection() const
Returns status on whether mask-detection is being performed.
static PFaceLog6Parameters BuildDefaultParameters(const papillon::PString &parametersPrefix=papillon::PString())
DEPRECATED: Builds default set of parameters.
PFaceLog6Parameters(const papillon::PString &parametersPrefix=papillon::PString())
Constructs a default set of parameters for FaceLog6.
double GetSightingSimilarity() const
Deprecated: Returns the recognition threshold parameter to use when considering to join two tracks to...
static papillon::PString GetFaceDetectorParametersPrefix()
#define DEFAULT_MAX_FRAME_RATE
void SetMinDetectionSize(papillon::int32 minDetectionSize)
Sets the minimum detection size in pixels for a face (face detector parameter).
void SetMaskDetection(bool maskDetection)
Perform mask-detection when running FaceLog6.
#define DEFAULT_GENDER_DETECTION
Class PWatchlist: a collection of PDescription typically used to detect a face from a list ok known p...
void SetFaceRecognition(bool faceRecognition)
Perform face-recognition when running FaceLog6.
#define DEFAULT_FACE_RECOGNITION