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

#include <multi_camera_projection.h>

apollo::perception::trafficlight::MultiCamerasProjection 的协作图:

Public 成员函数

 MultiCamerasProjection ()
 Construct a new multi cameras projection object.
 
 ~MultiCamerasProjection ()=default
 Destroy the multi cameras projection object.
 
bool Init (const MultiCamerasInitOption &options)
 multicamera project initialization parameters.
 
bool Project (const camera::CarPose &pose, const ProjectOption &option, base::TrafficLight *light) const
 Boundary projection based on vehicle position and traffic lights.
 
bool HasCamera (const std::string &camera_name) const
 Determine whether the camera exists.
 
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.
 
const std::vector< std::string > & getCameraNamesByDescendingFocalLen () const
 Get the camera names by descending focal len object.
 

详细描述

在文件 multi_camera_projection.h 第 41 行定义.

构造及析构函数说明

◆ MultiCamerasProjection()

apollo::perception::trafficlight::MultiCamerasProjection::MultiCamerasProjection ( )
inline

Construct a new multi cameras projection object.

在文件 multi_camera_projection.h 第 47 行定义.

47{}

◆ ~MultiCamerasProjection()

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

Destroy the multi cameras projection object.

成员函数说明

◆ getCameraNamesByDescendingFocalLen()

const std::vector< std::string > & apollo::perception::trafficlight::MultiCamerasProjection::getCameraNamesByDescendingFocalLen ( ) const
inline

Get the camera names by descending focal len object.

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

在文件 multi_camera_projection.h 第 99 行定义.

99 {
100 return camera_names_;
101 }

◆ getImageHeight()

int apollo::perception::trafficlight::MultiCamerasProjection::getImageHeight ( const std::string &  camera_name) const

Get the image height object.

参数
camera_name
返回
int

在文件 multi_camera_projection.cc 第 130 行定义.

131 {
132 if (!HasCamera(camera_name)) {
133 AERROR << "getImageHeight failed, camera_name: " << camera_name;
134 return -1;
135 }
136 return static_cast<int>(camera_models_.at(camera_name)->get_height());
137}
bool HasCamera(const std::string &camera_name) const
Determine whether the camera exists.
#define AERROR
Definition log.h:44

◆ getImageWidth()

int apollo::perception::trafficlight::MultiCamerasProjection::getImageWidth ( const std::string &  camera_name) const

Get the image width object.

参数
camera_name
返回
int

在文件 multi_camera_projection.cc 第 121 行定义.

122 {
123 if (!HasCamera(camera_name)) {
124 AERROR << "getImageWidth failed, camera_name: " << camera_name;
125 return -1;
126 }
127 return static_cast<int>(camera_models_.at(camera_name)->get_width());
128}

◆ HasCamera()

bool apollo::perception::trafficlight::MultiCamerasProjection::HasCamera ( const std::string &  camera_name) const

Determine whether the camera exists.

参数
camera_name
返回
true
false

在文件 multi_camera_projection.cc 第 114 行定义.

114 {
115 auto iter =
116 std::find(camera_names_.begin(), camera_names_.end(), camera_name);
117 return iter != camera_names_.end() &&
118 camera_models_.find(camera_name) != camera_models_.end();
119}

◆ Init()

bool apollo::perception::trafficlight::MultiCamerasProjection::Init ( const MultiCamerasInitOption &  options)

multicamera project initialization parameters.

参数
options
返回
true
false

在文件 multi_camera_projection.cc 第 35 行定义.

35 {
36 if (options.camera_names.empty()) {
37 AERROR << "no cameras to be projected";
38 return false;
39 }
40 algorithm::SensorManager* sensor_manager =
41 algorithm::SensorManager::Instance();
42 if (!sensor_manager->Init()) {
43 AERROR << "sensor_manager init failed";
44 }
45
46 for (size_t i = 0; i < options.camera_names.size(); ++i) {
47 const std::string& cur_camera_name = options.camera_names.at(i);
48 AINFO << "init camera " << cur_camera_name;
49
50 if (!sensor_manager->IsSensorExist(cur_camera_name)) {
51 AERROR << "sensor " << cur_camera_name << " do not exist";
52 return false;
53 }
54 camera_models_[cur_camera_name] =
55 std::dynamic_pointer_cast<base::BrownCameraDistortionModel>(
56 sensor_manager->GetDistortCameraModel(cur_camera_name));
57 if (!(camera_models_[cur_camera_name])) {
58 AERROR << "get null camera_model, camera_name: " << cur_camera_name;
59 return false;
60 }
61 camera_names_.push_back(cur_camera_name);
62 }
63 // sort camera_names_ by focal lengths (descending order)
64 std::sort(camera_names_.begin(), camera_names_.end(),
65 [&](const std::string& lhs, const std::string& rhs) {
66 const auto lhs_cam_intrinsics =
67 camera_models_[lhs]->get_intrinsic_params();
68 const auto rhs_cam_intrinsics =
69 camera_models_[rhs]->get_intrinsic_params();
70 auto lhs_focal_length =
71 0.5 * (lhs_cam_intrinsics(0, 0) + lhs_cam_intrinsics(1, 1));
72 auto rhs_focal_length =
73 0.5 * (rhs_cam_intrinsics(0, 0) + rhs_cam_intrinsics(1, 1));
74 return lhs_focal_length > rhs_focal_length;
75 });
76 AINFO << "camera_names sorted by descending focal lengths: "
77 << std::accumulate(camera_names_.begin(), camera_names_.end(),
78 std::string(""),
79 [](std::string& sum, const std::string& s) {
80 return sum + s + " ";
81 });
82
83 return true;
84}
#define AINFO
Definition log.h:42

◆ Project()

bool apollo::perception::trafficlight::MultiCamerasProjection::Project ( const camera::CarPose &  pose,
const ProjectOption &  option,
base::TrafficLight *  light 
) const

Boundary projection based on vehicle position and traffic lights.

参数
pose
option
light
返回
true
false

在文件 multi_camera_projection.cc 第 86 行定义.

88 {
89 if (!HasCamera(option.camera_name)) {
90 AERROR << "no camera: " << option.camera_name;
91 return false;
92 }
93
94 Eigen::Matrix4d c2w_pose;
95
96 if (pose.c2w_poses_.find(option.camera_name) == pose.c2w_poses_.end()) {
97 return false;
98 }
99 c2w_pose = pose.c2w_poses_.at(option.camera_name);
100
101 bool ret = false;
102 AINFO << "project use camera_name: " << option.camera_name;
103 ret = BoundaryBasedProject(camera_models_.at(option.camera_name), c2w_pose,
104 light->region.points, light);
105
106 if (!ret) {
107 AWARN << "Projection failed projection the traffic light. "
108 << "camera_name: " << option.camera_name;
109 return false;
110 }
111 return true;
112}
#define AWARN
Definition log.h:43

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