Apollo 11.0
自动驾驶开放平台
camera_location_estimation_component.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
17
18#include <string>
19
21
22namespace apollo {
23namespace perception {
24namespace camera {
25
26void CameraLocationEstimationComponent::InitTransformer(
27 const CameraLocationEstimation& location_estimation_param) {
28 TransformerInitOptions transformer_init_options;
29 auto plugin_param = location_estimation_param.plugin_param();
30 transformer_init_options.config_path = plugin_param.config_path();
31 transformer_init_options.config_file = plugin_param.config_file();
32 transformer_.reset(
33 BaseTransformerRegisterer::GetInstanceByName(plugin_param.name()));
34 ACHECK(transformer_ != nullptr);
35 ACHECK(transformer_->Init(transformer_init_options))
36 << "Failed to init: " << plugin_param.name();
37}
38
40 CameraLocationEstimation location_estimation_param;
41 if (!GetProtoConfig(&location_estimation_param)) {
42 AERROR << "Load camera location estimation component config failed!";
43 return false;
44 }
45
46 InitTransformer(location_estimation_param);
47
48 writer_ = node_->CreateWriter<onboard::CameraFrame>(
49 location_estimation_param.channel().output_obstacles_channel_name());
50 return true;
51}
52
54 const std::shared_ptr<onboard::CameraFrame>& msg) {
56 std::shared_ptr<onboard::CameraFrame> out_message(new (std::nothrow)
58 out_message->frame_id = msg->frame_id;
59 out_message->timestamp = msg->timestamp;
60 out_message->data_provider = msg->data_provider;
61 out_message->detected_objects = msg->detected_objects;
62 out_message->feature_blob = msg->feature_blob;
63 out_message->camera_k_matrix = msg->camera_k_matrix;
64 out_message->camera2world_pose = msg->camera2world_pose;
65
66 PERF_BLOCK("location_estimation_transform")
67 if (!transformer_->Transform(out_message.get())) {
68 AERROR << "Failed to transform.";
69 return false;
70 }
72
73 writer_->Write(out_message);
74 return true;
75}
76
77} // namespace camera
78} // namespace perception
79} // namespace apollo
bool GetProtoConfig(T *config) const
std::shared_ptr< Node > node_
bool Proc(const std::shared_ptr< onboard::CameraFrame > &msg) override
Process of camera location estimatation component.
bool Init() override
Init for camera location estimatation component.
#define ACHECK(cond)
Definition log.h:80
#define AERROR
Definition log.h:44
class register implement
Definition arena_queue.h:37
#define PERF_FUNCTION(...)
Definition profiler.h:54
#define PERF_BLOCK_END
Definition profiler.h:53
#define PERF_BLOCK(...)
Definition profiler.h:52