Apollo 10.0
自动驾驶开放平台
apollo::perception::base::Rect< T > 模板结构体 参考

#include <box.h>

apollo::perception::base::Rect< T > 的协作图:

Public 成员函数

 Rect ()
 
 Rect (const T &x_in, const T &y_in, const T &width_in, const T &height_in)
 
 Rect (const BBox2D< T > &bbox)
 
Rect< T > & operator= (const BBox2D< T > &bbox)
 
Point2D< T > Center () const
 
void SetCenter (Point2D< T > p)
 
Area () const
 
std::string ToStr () const
 

Public 属性

x = 0
 
y = 0
 
width = 0
 
height = 0
 

友元

Rect< T > operator& (const Rect< T > &rect1, const Rect< T > &rect2)
 
Rect< T > operator| (const Rect< T > &rect1, const Rect< T > &rect2)
 
bool operator== (const Rect &rect1, const Rect &rect2)
 
bool operator!= (const Rect &rect1, const Rect &rect2)
 

详细描述

template<typename T>
struct apollo::perception::base::Rect< T >

在文件 box.h33 行定义.

构造及析构函数说明

◆ Rect() [1/3]

template<typename T >
apollo::perception::base::Rect< T >::Rect ( )
inline

◆ Rect() [2/3]

template<typename T >
apollo::perception::base::Rect< T >::Rect ( const T &  x_in,
const T &  y_in,
const T &  width_in,
const T &  height_in 
)
inline

在文件 box.h36 行定义.

37 : x(x_in), y(y_in), width(width_in), height(height_in) {}

◆ Rect() [3/3]

template<typename T >
apollo::perception::base::Rect< T >::Rect ( const BBox2D< T > &  bbox)
inlineexplicit

在文件 box.h39 行定义.

39 {
40 this->x = bbox.xmin;
41 this->y = bbox.ymin;
42 this->width = bbox.xmax - bbox.xmin;
43 this->height = bbox.ymax - bbox.ymin;
44 }

成员函数说明

◆ Area()

template<typename T >
T apollo::perception::base::Rect< T >::Area ( ) const
inline

在文件 box.h66 行定义.

66{ return this->width * this->height; }

◆ Center()

template<typename T >
Point2D< T > apollo::perception::base::Rect< T >::Center ( ) const
inline

在文件 box.h54 行定义.

54 {
55 Point2D<T> p;
56 p.x = this->x + this->width / 2;
57 p.y = this->y + this->height / 2;
58 return p;
59 }

◆ operator=()

template<typename T >
Rect< T > & apollo::perception::base::Rect< T >::operator= ( const BBox2D< T > &  bbox)
inline

在文件 box.h46 行定义.

46 {
47 this->x = bbox.xmin;
48 this->y = bbox.ymin;
49 this->width = bbox.xmax - bbox.xmin;
50 this->height = bbox.ymax - bbox.ymin;
51 return *this;
52 }

◆ SetCenter()

template<typename T >
void apollo::perception::base::Rect< T >::SetCenter ( Point2D< T >  p)
inline

在文件 box.h61 行定义.

61 {
62 this->x = p.x - this->width / 2;
63 this->y = p.y - this->height / 2;
64 }

◆ ToStr()

template<typename T >
std::string apollo::perception::base::Rect< T >::ToStr ( ) const
inline

在文件 box.h68 行定义.

68 {
69 std::stringstream ss;
70 ss << "[ " << width << " x " << height << " ] from ( " << x << " , " << y
71 << " )";
72 return ss.str();
73 }

友元及相关函数文档

◆ operator!=

template<typename T >
bool operator!= ( const Rect< T > &  rect1,
const Rect< T > &  rect2 
)
friend

在文件 box.h113 行定义.

113 {
114 return !(rect1 == rect2);
115 }

◆ operator&

template<typename T >
Rect< T > operator& ( const Rect< T > &  rect1,
const Rect< T > &  rect2 
)
friend

在文件 box.h75 行定义.

75 {
76 T r1_xmin = rect1.x;
77 T r1_xmax = rect1.x + rect1.width;
78 T r1_ymin = rect1.y;
79 T r1_ymax = rect1.y + rect1.height;
80 T r2_xmin = rect2.x;
81 T r2_xmax = rect2.x + rect2.width;
82 T r2_ymin = rect2.y;
83 T r2_ymax = rect2.y + rect2.height;
84 if (r2_xmin <= r1_xmax && r2_xmax >= r1_xmin && r2_ymin <= r1_ymax &&
85 r2_ymax >= r1_ymin) {
86 T xmin = std::max(r1_xmin, r2_xmin);
87 T ymin = std::max(r1_ymin, r2_ymin);
88 T xmax = std::min(r1_xmax, r2_xmax);
89 T ymax = std::min(r1_ymax, r2_ymax);
90 return Rect<T>(xmin, ymin, xmax - xmin, ymax - ymin);
91 } else {
92 return Rect<T>(0, 0, 0, 0);
93 }
94 }

◆ operator==

template<typename T >
bool operator== ( const Rect< T > &  rect1,
const Rect< T > &  rect2 
)
friend

在文件 box.h107 行定义.

107 {
108 return (Equal(rect1.x, rect2.x) && Equal(rect1.y, rect2.y) &&
109 Equal(rect1.width, rect2.width) &&
110 Equal(rect1.height, rect2.height));
111 }
std::enable_if< std::is_integral< T >::value, bool >::type Equal(const T &lhs, const T &rhs)

◆ operator|

template<typename T >
Rect< T > operator| ( const Rect< T > &  rect1,
const Rect< T > &  rect2 
)
friend

在文件 box.h96 行定义.

96 {
97 Rect<T> ret;
98 ret.x = std::min(rect1.x, rect2.x);
99 ret.y = std::min(rect1.y, rect2.y);
100 ret.width = std::max(rect1.x + rect1.width, rect2.x + rect2.width) - ret.x;
101 ret.height =
102 std::max(rect1.y + rect1.height, rect2.y + rect2.height) - ret.y;
103
104 return ret;
105 }

类成员变量说明

◆ height

template<typename T >
T apollo::perception::base::Rect< T >::height = 0

在文件 box.h120 行定义.

◆ width

template<typename T >
T apollo::perception::base::Rect< T >::width = 0

在文件 box.h119 行定义.

◆ x

template<typename T >
T apollo::perception::base::Rect< T >::x = 0

在文件 box.h117 行定义.

◆ y

template<typename T >
T apollo::perception::base::Rect< T >::y = 0

在文件 box.h118 行定义.


该结构体的文档由以下文件生成: