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

#include <tl_preprocessor.h>

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

Public 成员函数

 TLPreprocessor ()=default
 Construct a new TLPreprocessor object.
 
 ~TLPreprocessor ()=default
 Destroy the TLPreprocessor object.
 
bool Init (const TrafficLightPreprocessorInitOptions &options) override
 Traffic light preprocessing initialization parameters.
 
std::string Name () const override
 returns the name of the preprocessing plugin.
 
bool UpdateCameraSelection (const camera::CarPose &pose, const TLPreprocessorOption &option, std::vector< base::TrafficLightPtr > *lights) override
 Select the appropriate camera for preprocessing according to the position of the vehicle and the position of the traffic light.
 
bool SyncInformation (const double ts, const std::string &camera_name)
 Determine whether the selected camera is available and synchronize timestamp information.
 
bool UpdateLightsProjection (const camera::CarPose &pose, const TLPreprocessorOption &option, const std::string &camera_name, std::vector< base::TrafficLightPtr > *lights) override
 Update the traffic light projection status and determine whether the projection exceeds the boundary range.
 
bool SetCameraWorkingFlag (const std::string &camera_name, bool is_working) override
 Set the camera working flag object.
 
bool GetCameraWorkingFlag (const std::string &camera_name, bool *is_working) const override
 Get the camera working flag object.
 
const std::vector< std::string > & GetCameraNamesByDescendingFocalLen () const override
 Get the camera names by descending focal len object.
 
bool GetAlllightsOutsideFlag () const
 Get all projections outside the image.
 
- Public 成员函数 继承自 apollo::perception::trafficlight::BaseTLPreprocessor
 BaseTLPreprocessor ()=default
 Construct a new base trafficlight preprocessor object.
 
virtual ~BaseTLPreprocessor ()=default
 Destroy the base trafficlight preprocessor object.
 

详细描述

在文件 tl_preprocessor.h 第 37 行定义.

构造及析构函数说明

◆ TLPreprocessor()

apollo::perception::trafficlight::TLPreprocessor::TLPreprocessor ( )
default

Construct a new TLPreprocessor object.

◆ ~TLPreprocessor()

apollo::perception::trafficlight::TLPreprocessor::~TLPreprocessor ( )
default

Destroy the TLPreprocessor object.

成员函数说明

◆ GetAlllightsOutsideFlag()

bool apollo::perception::trafficlight::TLPreprocessor::GetAlllightsOutsideFlag ( ) const

Get all projections outside the image.

返回
true
false

在文件 tl_preprocessor.cc 第 324 行定义.

324 {
325 return projections_outside_all_images_;
326}

◆ GetCameraNamesByDescendingFocalLen()

const std::vector< std::string > & apollo::perception::trafficlight::TLPreprocessor::GetCameraNamesByDescendingFocalLen ( ) const
inlineoverridevirtual

Get the camera names by descending focal len object.

返回
const std::vector<std::string>&

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

在文件 tl_preprocessor.h 第 127 行定义.

127 {
128 return projection_.getCameraNamesByDescendingFocalLen();
129 }
const std::vector< std::string > & getCameraNamesByDescendingFocalLen() const
Get the camera names by descending focal len object.

◆ GetCameraWorkingFlag()

bool apollo::perception::trafficlight::TLPreprocessor::GetCameraWorkingFlag ( const std::string &  camera_name,
bool *  is_working 
) const
overridevirtual

Get the camera working flag object.

参数
camera_name
is_working
返回
true
false

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

在文件 tl_preprocessor.cc 第 162 行定义.

163 {
164 if (!projection_.HasCamera(camera_name)) {
165 AERROR << "GetCameraWorkingFlag failed, "
166 << "get invalid camera_name: " << camera_name;
167 return false;
168 }
169
170 if (camera_is_working_flags_.find(camera_name) ==
171 camera_is_working_flags_.end() ||
172 !camera_is_working_flags_.at(camera_name)) {
173 *is_working = false;
174 } else {
175 *is_working = true;
176 }
177 return true;
178}
bool HasCamera(const std::string &camera_name) const
Determine whether the camera exists.
#define AERROR
Definition log.h:44

◆ Init()

bool apollo::perception::trafficlight::TLPreprocessor::Init ( const TrafficLightPreprocessorInitOptions &  options)
overridevirtual

Traffic light preprocessing initialization parameters.

参数
options
返回
true
false

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

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

26 {
27 trafficlight::MultiCamerasInitOption projection_init_option;
28 projection_init_option.camera_names = options.camera_names;
29 if (!projection_.Init(projection_init_option)) {
30 AERROR << "init multi_camera_projection failed.";
31 return false;
32 }
33
34 num_cameras_ = projection_.getCameraNamesByDescendingFocalLen().size();
35 lights_on_image_array_.resize(num_cameras_);
36 lights_outside_image_array_.resize(num_cameras_);
37 sync_interval_seconds_ = options.sync_interval_seconds;
38
39 AINFO << "preprocessor init succeed";
40
41 return true;
42}
bool Init(const MultiCamerasInitOption &options)
multicamera project initialization parameters.
#define AINFO
Definition log.h:42

◆ Name()

std::string apollo::perception::trafficlight::TLPreprocessor::Name ( ) const
overridevirtual

returns the name of the preprocessing plugin.

返回
std::string

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

在文件 tl_preprocessor.cc 第 328 行定义.

328{ return "TLPreprocessor"; }

◆ SetCameraWorkingFlag()

bool apollo::perception::trafficlight::TLPreprocessor::SetCameraWorkingFlag ( const std::string &  camera_name,
bool  is_working 
)
overridevirtual

Set the camera working flag object.

参数
camera_name
is_working
返回
true
false

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

在文件 tl_preprocessor.cc 第 149 行定义.

150 {
151 if (!projection_.HasCamera(camera_name)) {
152 AERROR << "SetCameraWorkingFlag failed, "
153 << "get invalid camera_name: " << camera_name;
154 return false;
155 }
156 camera_is_working_flags_[camera_name] = is_working;
157 AINFO << "SetCameraWorkingFlag succeeded, camera_name: " << camera_name
158 << ", flag: " << camera_is_working_flags_[camera_name];
159 return true;
160}

◆ SyncInformation()

bool apollo::perception::trafficlight::TLPreprocessor::SyncInformation ( const double  ts,
const std::string &  camera_name 
)
virtual

Determine whether the selected camera is available and synchronize timestamp information.

参数
ts
camera_name
返回
true
false

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

在文件 tl_preprocessor.cc 第 69 行定义.

70 {
71 const double &proj_ts = selected_camera_name_.first;
72 const std::string &proj_camera_name = selected_camera_name_.second;
73 AINFO << "ready to sync information";
74
75 if (!projection_.HasCamera(cam_name)) {
76 AERROR << "sync_image failed, "
77 << "get invalid camera_name: " << cam_name;
78 return false;
79 }
80
81 AINFO << "Enter TLPreprocessor::sync_image. proj_ts: " << proj_ts
82 << " proj_camera_name: " << proj_camera_name
83 << " image_ts: " << image_timestamp
84 << " image_camera_name: " << cam_name;
85 if (image_timestamp < last_pub_img_ts_) {
86 AWARN << "TLPreprocessor reject the image pub ts:" << image_timestamp
87 << " which is earlier than last output ts:" << last_pub_img_ts_
88 << ", image_camera_name: " << cam_name;
89 return false;
90 }
91
92 if (proj_camera_name != cam_name) {
93 AWARN << "sync_image failed - find close enough projection,"
94 << "but camera_name not match.";
95 return false;
96 }
97 AINFO << "sync_image succeeded.";
98 last_pub_img_ts_ = image_timestamp;
99 return true;
100}
#define AWARN
Definition log.h:43

◆ UpdateCameraSelection()

bool apollo::perception::trafficlight::TLPreprocessor::UpdateCameraSelection ( const camera::CarPose &  pose,
const TLPreprocessorOption &  option,
std::vector< base::TrafficLightPtr > *  lights 
)
overridevirtual

Select the appropriate camera for preprocessing according to the position of the vehicle and the position of the traffic light.

参数
pose
option
lights
返回
true
false

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

在文件 tl_preprocessor.cc 第 44 行定义.

46 {
47 const double &timestamp = pose.getTimestamp();
48 selected_camera_name_.first = timestamp;
49 selected_camera_name_.second = GetMaxFocalLenWorkingCameraName();
50
51 AINFO << "TLPreprocessor Got signal number: " << lights->size()
52 << ", ts: " << timestamp;
53 if (lights->empty()) {
54 AINFO << "No signals, select camera with max focal length: "
55 << selected_camera_name_.second;
56 return true;
57 }
58
59 if (!ProjectLightsAndSelectCamera(pose, option,
60 &(selected_camera_name_.second), lights)) {
61 AERROR << "project_lights_and_select_camera failed, ts: " << timestamp;
62 }
63
64 AINFO << "selected_camera_id: " << selected_camera_name_.second;
65
66 return true;
67}

◆ UpdateLightsProjection()

bool apollo::perception::trafficlight::TLPreprocessor::UpdateLightsProjection ( const camera::CarPose &  pose,
const TLPreprocessorOption &  option,
const std::string &  camera_name,
std::vector< base::TrafficLightPtr > *  lights 
)
overridevirtual

Update the traffic light projection status and determine whether the projection exceeds the boundary range.

参数
pose
option
camera_name
lights
返回
true
false

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

在文件 tl_preprocessor.cc 第 102 行定义.

105 {
106 lights_on_image_.clear();
107 lights_outside_image_.clear();
108
109 AINFO << "clear lights_outside_image_ " << lights_outside_image_.size();
110
111 if (lights->empty()) {
112 AINFO << "No lights to be projected";
113 return true;
114 }
115
116 if (!ProjectLights(pose, camera_name, lights, &lights_on_image_,
117 &lights_outside_image_)) {
118 AERROR << "update_lights_projection project lights on " << camera_name
119 << " image failed";
120 return false;
121 }
122
123 if (lights_outside_image_.size() > 0) {
124 AERROR << "update_lights_projection failed,"
125 << "lights_outside_image->size() " << lights_outside_image_.size()
126 << " ts: " << pose.getTimestamp();
127 return false;
128 }
129
130 auto min_focal_len_working_camera = GetMinFocalLenWorkingCameraName();
131 if (camera_name == min_focal_len_working_camera) {
132 return lights_on_image_.size() > 0;
133 }
134 for (const base::TrafficLightPtr &light : lights_on_image_) {
135 if (camera::OutOfValidRegion(light->region.projection_roi,
136 projection_.getImageWidth(camera_name),
137 projection_.getImageHeight(camera_name),
138 option.image_borders_size->at(camera_name))) {
139 AINFO << "update_lights_projection light project out of image region. "
140 << "camera_name: " << camera_name;
141 return false;
142 }
143 }
144
145 AINFO << "UpdateLightsProjection success";
146 return true;
147}
int getImageWidth(const std::string &camera_name) const
Get the image width object.
int getImageHeight(const std::string &camera_name) const
Get the image height object.
std::shared_ptr< TrafficLight > TrafficLightPtr
bool OutOfValidRegion(const base::BBox2D< T > box, const T width, const T height, const T border_size=0)
Definition util.h:74

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