Main Page
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Functions
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
Variables
b
c
d
e
h
i
l
m
n
p
r
s
u
x
Typedefs
b
c
d
e
f
g
i
m
p
r
u
v
Enumerations
Enumerator
a
b
f
g
i
m
n
r
s
u
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
h
i
m
n
p
q
r
s
t
u
v
x
Enumerations
a
c
d
e
f
k
l
m
p
r
s
t
v
w
Enumerator
a
b
d
f
g
h
i
l
m
n
o
p
r
s
u
v
Related Functions
Files
File List
File Members
All
_
a
b
c
d
e
f
g
i
k
l
m
n
o
p
r
s
t
u
v
w
Functions
b
c
d
e
f
g
m
o
p
r
s
t
u
v
w
Variables
a
b
c
d
e
f
i
k
l
m
n
o
p
r
s
t
w
Typedefs
Enumerations
Enumerator
Macros
_
d
f
i
m
n
p
s
t
u
shared
depthai-shared
include
depthai-shared
common
Rect.hpp
Go to the documentation of this file.
1
#pragma once
2
3
// libraries
4
#include <algorithm>
5
6
#include "
depthai-shared/common/Point2f.hpp
"
7
#include "
depthai-shared/common/Size2f.hpp
"
8
#include "
depthai-shared/utility/Serialization.hpp
"
9
10
namespace
dai
{
11
18
struct
Rect
{
19
// default constructor
20
Rect
() =
default
;
21
Rect
(
float
x
,
float
y
,
float
width
,
float
height
) :
x
(
x
),
y
(
y
),
width
(
width
),
height
(
height
) {}
22
Rect
(
const
Rect
& r) :
x
(r.
x
),
y
(r.
y
),
width
(r.
width
),
height
(r.
height
) {}
23
Rect
(
const
Point2f
& org,
const
Size2f
& sz) :
x
(org.
x
),
y
(org.
y
),
width
(sz.
width
),
height
(sz.
height
) {}
24
Rect
(
const
Point2f
& pt1,
const
Point2f
& pt2)
25
:
x
(
std
::min(pt1.
x
, pt2.
x
)),
y
(
std
::min(pt1.
y
, pt2.
y
)),
width
(
std
::max(pt1.
x
, pt2.
x
) -
x
),
height
(
std
::max(pt1.
y
, pt2.
y
) -
y
) {}
26
Rect
&
operator=
(
const
Rect
& r) =
default
;
27
Rect
&
operator=
(
Rect
&& r) =
default
;
28
32
Point2f
topLeft
()
const
{
33
return
Point2f
(
x
,
y
);
34
}
35
39
Point2f
bottomRight
()
const
{
40
return
Point2f
(
x
+
width
,
y
+
height
);
41
}
42
46
Size2f
size
()
const
{
47
return
Size2f
(
width
,
height
);
48
}
49
53
float
area
()
const
{
54
return
width
*
height
;
55
}
56
60
bool
empty
()
const
{
61
return
width
<= 0 ||
height
<= 0;
62
}
63
67
bool
contains
(
const
Point2f
& pt)
const
{
68
return
x
<= pt.
x
&& pt.
x
<
x
+
width
&&
y
<= pt.
y
&& pt.
y
<
y
+
height
;
69
}
70
74
bool
isNormalized
()
const
{
75
if
(
x
+
width
<= 1.f &&
y
+
height
<= 1.f)
return
true
;
76
return
!(
x
==
static_cast<
int
>
(
x
) &&
y
==
static_cast<
int
>
(
y
) &&
width
==
static_cast<
int
>
(
width
) &&
height
==
static_cast<
int
>
(
height
));
77
}
78
84
Rect
denormalize
(
int
destWidth,
int
destHeight)
const
{
85
if
(
isNormalized
()) {
86
return
Rect
(std::round(
x
* destWidth), std::round(
y
* destHeight), std::round(
width
* destWidth), std::round(
height
* destHeight));
87
}
88
return
*
this
;
89
}
90
96
Rect
normalize
(
int
srcWidth,
int
srcHeight)
const
{
97
if
(
isNormalized
()) {
98
return
*
this
;
99
}
100
return
Rect
(
x
/ srcWidth,
y
/ srcHeight,
width
/ srcWidth,
height
/ srcHeight);
101
}
102
103
// order of declaration must be x, y, width, height for constructor initializer lists
104
float
x
= 0.0f;
// x coordinate of the top-left corner
105
float
y
= 0.0f;
// y coordinate of the top-left corner
106
float
width
= 0.0f;
// width of the rectangle
107
float
height
= 0.0f;
// height of the rectangle
108
};
109
DEPTHAI_SERIALIZE_EXT
(
Rect
, x, y, width, height);
110
111
}
// namespace dai
dai::Rect::topLeft
Point2f topLeft() const
Definition:
Rect.hpp:32
dai::Rect::denormalize
Rect denormalize(int destWidth, int destHeight) const
Definition:
Rect.hpp:84
dai::Rect::x
float x
Definition:
Rect.hpp:104
dai::Rect::normalize
Rect normalize(int srcWidth, int srcHeight) const
Definition:
Rect.hpp:96
dai::DEPTHAI_SERIALIZE_EXT
DEPTHAI_SERIALIZE_EXT(CameraSensorConfig, width, height, minFps, maxFps, fov, type)
dai::Rect::empty
bool empty() const
Definition:
Rect.hpp:60
dai::Rect::Rect
Rect()=default
dai::Point2f
Definition:
Point2f.hpp:16
dai::Rect::size
Size2f size() const
Definition:
Rect.hpp:46
dai::Rect::bottomRight
Point2f bottomRight() const
Definition:
Rect.hpp:39
dai::Rect::Rect
Rect(const Point2f &org, const Size2f &sz)
Definition:
Rect.hpp:23
dai::Rect::Rect
Rect(const Rect &r)
Definition:
Rect.hpp:22
dai::Rect::isNormalized
bool isNormalized() const
Definition:
Rect.hpp:74
dai::Size2f
Definition:
Size2f.hpp:15
dai::Rect::contains
bool contains(const Point2f &pt) const
Definition:
Rect.hpp:67
Serialization.hpp
Size2f.hpp
Point2f.hpp
std
Definition:
Node.hpp:366
dai::Point2f::x
float x
Definition:
Point2f.hpp:19
dai::Rect
Definition:
Rect.hpp:18
dai::Rect::Rect
Rect(float x, float y, float width, float height)
Definition:
Rect.hpp:21
dai::Rect::height
float height
Definition:
Rect.hpp:107
dai::Rect::operator=
Rect & operator=(const Rect &r)=default
dai::Point2f::y
float y
Definition:
Point2f.hpp:19
dai::Rect::Rect
Rect(const Point2f &pt1, const Point2f &pt2)
Definition:
Rect.hpp:24
dai::Rect::width
float width
Definition:
Rect.hpp:106
dai
Definition:
CameraExposureOffset.hpp:6
dai::Rect::y
float y
Definition:
Rect.hpp:105
dai::Rect::area
float area() const
Definition:
Rect.hpp:53
depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:19