Apollo 11.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 第 42 行定义.

构造及析构函数说明

◆ 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 第 81 行定义.

81 {
82 Init(crop_scale, min_crop_size);
83}
void Init(float crop_scale, int min_crop_size)
Initialize crop box object parameters.
Definition cropbox.cc:77

成员函数说明

◆ 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 行定义.

26 {
27 int rows = height;
28 int cols = width;
29
30 if (camera::OutOfValidRegion(light->region.projection_roi, width, height)
31 || light->region.projection_roi.Area() <= 0) {
32 crop_box->x = 0;
33 crop_box->y = 0;
34 crop_box->width = 0;
35 crop_box->height = 0;
36 return;
37 }
38
39 int xl = light->region.projection_roi.x;
40 int yt = light->region.projection_roi.y;
41 int xr = xl + light->region.projection_roi.width - 1;
42 int yb = yt + light->region.projection_roi.height - 1;
43
44 // scale
45 int center_x = (xr + xl) / 2;
46 int center_y = (yb + yt) / 2;
47 int resize = static_cast<int>(
48 crop_scale_
49 * static_cast<float>(std::max(light->region.projection_roi.width, light->region.projection_roi.height)));
50
51 resize = std::max(resize, min_crop_size_);
52 resize = std::min(resize, width);
53 resize = std::min(resize, height);
54
55 // clamp
56 xl = center_x - resize / 2 + 1;
57 xl = (xl < 0) ? 0 : xl;
58 yt = center_y - resize / 2 + 1;
59 yt = (yt < 0) ? 0 : yt;
60 xr = xl + resize - 1;
61 yb = yt + resize - 1;
62 if (xr >= cols - 1) {
63 xl -= xr - cols + 1;
64 xr = cols - 1;
65 }
66
67 if (yb >= rows - 1) {
68 yt -= yb - rows + 1;
69 yb = rows - 1;
70 }
71
72 crop_box->x = xl;
73 crop_box->y = yt;
74 crop_box->width = xr - xl + 1;
75 crop_box->height = yb - yt + 1;
76}
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 第 77 行定义.

77 {
78 crop_scale_ = crop_scale;
79 min_crop_size_ = min_crop_size;
80}

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