|
20 | 20 | #include "Eigen/Core"
|
21 | 21 | #include "Eigen/Dense"
|
22 | 22 |
|
| 23 | +#include "modules/common/util/file.h" |
23 | 24 | #include "modules/perception/traffic_light/base/tl_shared_data.h"
|
24 | 25 |
|
25 | 26 | namespace apollo {
|
26 | 27 | namespace perception {
|
27 | 28 | namespace traffic_light {
|
28 | 29 |
|
| 30 | +using apollo::common::util::GetProtoFromFile; |
| 31 | + |
29 | 32 | bool MultiCamerasProjection::Init() {
|
30 |
| - ConfigManager *config_manager = ConfigManager::instance(); |
31 |
| - std::string model_name = "MultiCamerasProjection"; |
32 |
| - const ModelConfig *model_config = config_manager->GetModelConfig(model_name); |
33 |
| - if (model_config == nullptr) { |
34 |
| - AERROR << "not found model: " << model_name; |
| 33 | + if (!GetProtoFromFile(FLAGS_traffic_light_multi_camera_projection_config, |
| 34 | + &config_)) { |
| 35 | + AERROR << "Cannot get config proto from file: " |
| 36 | + << FLAGS_traffic_light_multi_camera_projection_config; |
35 | 37 | return false;
|
36 | 38 | }
|
37 |
| - |
38 | 39 | // Read camera names from config file
|
39 |
| - std::vector<std::string> camera_names; |
40 |
| - std::string single_projection_name; |
41 |
| - if (!model_config->GetValue("camera_names", &camera_names)) { |
42 |
| - AERROR << "camera_names not found." << name(); |
43 |
| - return false; |
44 |
| - } |
45 |
| - if (!model_config->GetValue("SingleProjection", &single_projection_name)) { |
46 |
| - AERROR << "SingleProjection not found." << name(); |
47 |
| - return false; |
48 |
| - } |
49 |
| - |
50 |
| - AINFO << "number of camera_names: " << camera_names.size(); |
51 |
| - AINFO << "SingleProjection name: " << single_projection_name; |
| 40 | + const std::string &single_projection_name = |
| 41 | + config_.multi_camera_projection_config().single_projection(); |
52 | 42 |
|
53 | 43 | // Read each camera's config
|
54 |
| - std::string camera_extrinsic_file; |
55 |
| - std::string camera_intrinsic_file; |
56 | 44 | std::unordered_map<std::string, CameraCoeffient> camera_coeffients;
|
57 |
| - for (size_t i = 0; i < camera_names.size(); ++i) { |
58 |
| - const auto &camera_model_name = camera_names[i]; |
59 |
| - const ModelConfig *camera_model_config = |
60 |
| - config_manager->GetModelConfig(camera_model_name); |
61 |
| - if (camera_model_config == nullptr) { |
62 |
| - AERROR << "not found camera model: " << camera_model_name; |
63 |
| - return false; |
64 |
| - } |
65 |
| - |
66 |
| - if (!camera_model_config->GetValue("camera_extrinsic_file", |
67 |
| - &camera_extrinsic_file)) { |
68 |
| - AERROR << "camera_extrinsic_file not found." << name(); |
69 |
| - return false; |
70 |
| - } |
71 |
| - if (!camera_model_config->GetValue("camera_intrinsic_file", |
72 |
| - &camera_intrinsic_file)) { |
73 |
| - AERROR << "camera_intrinsic_file not found." << name(); |
74 |
| - return false; |
75 |
| - } |
76 |
| - |
| 45 | + for (const auto &camera_focus_config : |
| 46 | + config_.multi_camera_projection_config().camera_focus_config()) { |
| 47 | + const auto &camera_model_name = camera_focus_config.name(); |
77 | 48 | CameraCoeffient camera_coeffient;
|
78 |
| - if (!camera_coeffient.init(camera_model_name, camera_extrinsic_file, |
79 |
| - camera_intrinsic_file)) { |
| 49 | + if (!camera_coeffient.init(camera_model_name, |
| 50 | + camera_focus_config.camera_extrinsic_file(), |
| 51 | + camera_focus_config.camera_intrinsic_file())) { |
80 | 52 | AERROR << camera_model_name << " Projection init failed.";
|
81 | 53 | return false;
|
82 | 54 | }
|
83 |
| - AINFO << "init " << camera_names[i] << " coeffient succeeded."; |
84 |
| - camera_coeffients[camera_names[i]] = camera_coeffient; |
85 |
| - camera_names_.push_back(camera_names[i]); |
| 55 | + camera_coeffients[camera_model_name] = camera_coeffient; |
| 56 | + camera_names_.push_back(camera_model_name); |
86 | 57 | }
|
87 | 58 |
|
88 | 59 | projection_.reset(
|
|
0 commit comments