Face Engine SDK  5.21.0
A face detection, recognition and tracking engine.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Detection.h
1 #pragma once
2 
3 #include <fsdk/Types/Rect.h>
4 
5 namespace fsdk {
10  struct Detection {
14  Detection() noexcept
15  : m_rect{}
16  , m_w{0}
17  , m_h{0}
18  , m_score{0.0f} {
19  }
20 
28  Detection(FloatRect rect, float score = 1.f) noexcept
29  : m_rect{rect}
30  , m_w{static_cast<int>(rect.x + rect.width)}
31  , m_h{static_cast<int>(rect.y + rect.height)}
32  , m_score{score} {
33  }
34 
42  Detection(FloatRect rect, int width, int height, float score = 1.f) noexcept
43  : m_rect{rect}
44  , m_w{width}
45  , m_h{height}
46  , m_score{score} {
47  }
48 
54  Detection(FloatRect rect, Rect imageRect, float score = 1.f) noexcept
55  : m_rect{rect}
56  , m_w{imageRect.x + imageRect.width}
57  , m_h{imageRect.y + imageRect.height}
58  , m_score{score} {
59  }
60 
61  Detection(const Detection& rhs) noexcept
62  : m_rect{rhs.m_rect}
63  , m_w{rhs.m_w}
64  , m_h{rhs.m_h}
65  , m_score{rhs.m_score} {
66  }
67 
68  Detection& operator=(const Detection& rhs) noexcept {
69  m_rect = rhs.m_rect;
70  m_w = rhs.m_w;
71  m_h = rhs.m_h;
72  m_score = rhs.m_score;
73  return *this;
74  }
75 
80  Rect getRect() const noexcept {
81  return m_rect & fsdk::Rect{0, 0, m_w, m_h};
82  }
83 
88  FloatRect getRawRect() const noexcept {
89  return m_rect;
90  }
91 
97  void setRawRect(fsdk::FloatRect rect) noexcept {
98  m_rect = rect;
99  }
100 
101  float getScore() const noexcept {
102  return m_score;
103  }
104 
110  void setScore(float score) noexcept {
111  m_score = score;
112  }
113 
119  bool isValid() const noexcept {
120  return m_rect.isValid() && m_score && m_w && m_h;
121  }
122 
123  private:
124  FloatRect m_rect; // Detection rect
125  int m_w, m_h; // Bounding width and height of the source image
126  float m_score; // Detection score
127  };
128 } // namespace fsdk
FloatRect getRawRect() const noexcept
Returns a raw detection bounding box.
Definition: Detection.h:88
void setScore(float score) noexcept
Sets a detection score.
Definition: Detection.h:110
bool isValid() const noexcept
Checks whether a detection is valid.
Definition: Detection.h:119
Detection(FloatRect rect, float score=1.f) noexcept
Special constructor based on raw rect and score only.
Definition: Detection.h:28
bool isValid() const noexcept
Checks whether a rect is valid.
Definition: Rect.h:372
Detection() noexcept
Default constructor. Creates an invalid Detection with zeroed rect and score.
Definition: Detection.h:14
Detection(FloatRect rect, int width, int height, float score=1.f) noexcept
Constructor base on the raw rect, bounding width and height.
Definition: Detection.h:42
Detection(FloatRect rect, Rect imageRect, float score=1.f) noexcept
Constructor base on the raw rect, bounding width and height.
Definition: Detection.h:54
void setRawRect(fsdk::FloatRect rect) noexcept
Sets a detection rect.
Definition: Detection.h:97
Detection structure. Stores a detected bounding box within a source image rect.
Definition: Detection.h:10
Rect getRect() const noexcept
Returns a detection rect.
Definition: Detection.h:80