Apollo 10.0
自动驾驶开放平台
apollo::perception::trafficlight::CropBox类 参考

#include <cropbox.h>

类 apollo::perception::trafficlight::CropBox 继承关系图:
apollo::perception::trafficlight::CropBox 的协作图:

Public 成员函数

 CropBox (float crop_scale, int min_crop_size)
 Construct a new crop box object.
 
void Init (float crop_scale, int min_crop_size)
 Initialize crop box object parameters.
 
virtual void getCropBox (const int width, const int height, const base::TrafficLightPtr &light, base::RectI *crop_box)
 Get the crop box object.
 

详细描述

在文件 cropbox.h 第 39 行定义.

构造及析构函数说明

◆ CropBox()

apollo::perception::trafficlight::CropBox::CropBox ( float  crop_scale,
int  min_crop_size 
)

Construct a new crop box object.

参数
crop_scale
min_crop_size

在文件 cropbox.cc 第 84 行定义.

84 {
85 Init(crop_scale, min_crop_size);
86}
void Init(float crop_scale, int min_crop_size)
Initialize crop box object parameters.
Definition cropbox.cc:80

成员函数说明

◆ getCropBox()

void apollo::perception::trafficlight::CropBox::getCropBox ( const int  width,
const int  height,
const base::TrafficLightPtr &  light,
base::RectI *  crop_box 
)
virtual

Get the crop box object.

参数
width
height
light
crop_box

实现了 apollo::perception::trafficlight::IGetBox.

在文件 cropbox.cc 第 26 行定义.

28 {
29 int rows = height;
30 int cols = width;
31
32 if (camera::OutOfValidRegion(light->region.projection_roi, width, height) ||
33 light->region.projection_roi.Area() <= 0) {
34 crop_box->x = 0;
35 crop_box->y = 0;
36 crop_box->width = 0;
37 crop_box->height = 0;
38 return;
39 }
40
41 int xl = light->region.projection_roi.x;
42 int yt = light->region.projection_roi.y;
43 int xr = xl + light->region.projection_roi.width - 1;
44 int yb = yt + light->region.projection_roi.height - 1;
45
46 // scale
47 int center_x = (xr + xl) / 2;
48 int center_y = (yb + yt) / 2;
49 int resize =
50 static_cast<int>(crop_scale_ * static_cast<float>(std::max(
51 light->region.projection_roi.width,
52 light->region.projection_roi.height)));
53
54 resize = std::max(resize, min_crop_size_);
55 resize = std::min(resize, width);
56 resize = std::min(resize, height);
57
58 // clamp
59 xl = center_x - resize / 2 + 1;
60 xl = (xl < 0) ? 0 : xl;
61 yt = center_y - resize / 2 + 1;
62 yt = (yt < 0) ? 0 : yt;
63 xr = xl + resize - 1;
64 yb = yt + resize - 1;
65 if (xr >= cols - 1) {
66 xl -= xr - cols + 1;
67 xr = cols - 1;
68 }
69
70 if (yb >= rows - 1) {
71 yt -= yb - rows + 1;
72 yb = rows - 1;
73 }
74
75 crop_box->x = xl;
76 crop_box->y = yt;
77 crop_box->width = xr - xl + 1;
78 crop_box->height = yb - yt + 1;
79}
uint32_t height
Height of point cloud
uint32_t width
Width of point cloud
bool OutOfValidRegion(const base::BBox2D< T > box, const T width, const T height, const T border_size=0)
Definition util.h:74

◆ Init()

void apollo::perception::trafficlight::CropBox::Init ( float  crop_scale,
int  min_crop_size 
)

Initialize crop box object parameters.

参数
crop_scale
min_crop_size

在文件 cropbox.cc 第 80 行定义.

80 {
81 crop_scale_ = crop_scale;
82 min_crop_size_ = min_crop_size;
83}

该类的文档由以下文件生成: