| Face Engine SDK 5.7.0 A face detection, recognition and tracking engine.

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}, m_h{0}
17 , m_score{0.0f}
18 {}
19
27 Detection(FloatRect rect, float score = 1.f) noexcept
28 : m_rect{rect}
29 , m_w{static_cast<int>(rect.x + rect.width)}
30 , m_h{static_cast<int>(rect.y + rect.height)}
31 , m_score{score}
32 {}
33
41 Detection(FloatRect rect, int width, int height, float score = 1.f) noexcept
42 : m_rect{rect}
43 , m_w{width}, m_h{height}
44 , m_score{score}
45 {}
46
52 Detection(FloatRect rect, Rect imageRect, float score = 1.f) noexcept
53 : m_rect{rect}
54 , m_w{imageRect.x + imageRect.width}, m_h{imageRect.y + imageRect.height}
55 , m_score{score}
56 {}
57
58 Detection(const Detection& rhs) noexcept
59 : m_rect{rhs.m_rect}
60 , m_w{rhs.m_w}
61 , m_h{rhs.m_h}
62 , m_score{rhs.m_score}
63 {}
64
65 Detection& operator=(const Detection& rhs) noexcept {
66 m_rect = rhs.m_rect;
67 m_w = rhs.m_w;
68 m_h = rhs.m_h;
69 m_score = rhs.m_score;
70 return *this;
71 }
72
77 Rect getRect() const noexcept {
78 return m_rect & fsdk::Rect{0, 0, m_w, m_h};
79 }
80
85 FloatRect getRawRect() const noexcept {
86 return m_rect;
87 }
88
94 void setRawRect(fsdk::FloatRect rect) noexcept {
95 m_rect = rect;
96 }
97
98 float getScore() const noexcept {
99 return m_score;
100 }
101
107 void setScore(float score) noexcept {
108 m_score = score;
109 }
110
116 bool isValid() const noexcept {
117 return m_rect.isValid() && m_score && m_w && m_h;
118 }
119 private:
120 FloatRect m_rect; // Detection rect
121 int m_w, m_h; // Bounding width and height of the source image
122 float m_score; // Detection score
123 };
124 }
fsdk::Detection::setRawRect
void setRawRect(fsdk::FloatRect rect) noexcept
Sets a detection rect.
Definition: Detection.h:94
fsdk::Detection::Detection
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:41
fsdk::Detection::Detection
Detection(FloatRect rect, float score=1.f) noexcept
Special constructor based on raw rect and score only.
Definition: Detection.h:27
fsdk
SDK namespace.
Definition: IAGSEstimator.h:8
fsdk::BaseRect< float >
fsdk::Detection::isValid
bool isValid() const noexcept
Checks whether a detection is valid.
Definition: Detection.h:116
fsdk::Detection::setScore
void setScore(float score) noexcept
Sets a detection score.
Definition: Detection.h:107
fsdk::Detection::Detection
Detection() noexcept
Default constructor. Creates an invalid Detection with zeroed rect and score.
Definition: Detection.h:14
fsdk::Detection::getRawRect
FloatRect getRawRect() const noexcept
Returns a raw detection bounding box.
Definition: Detection.h:85
fsdk::Detection
Detection structure. @detail Stores a detected bounding box within a source image rect.
Definition: Detection.h:10
fsdk::Detection::getRect
Rect getRect() const noexcept
Returns a detection rect.
Definition: Detection.h:77
fsdk::BaseRect::isValid
bool isValid() const noexcept
Checks whether a rect is valid.
Definition: Rect.h:366
fsdk::Detection::Detection
Detection(FloatRect rect, Rect imageRect, float score=1.f) noexcept
Constructor base on the raw rect, bounding width and height.
Definition: Detection.h:52