Apollo 10.0
自动驾驶开放平台
camera_detection_occupancy_component.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2024 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 *****************************************************************************/
16#pragma once
17
18#include <memory>
19#include <string>
20#include <vector>
21
22#include "yaml-cpp/yaml.h"
23
24#include "modules/common_msgs/perception_msgs/perception_obstacle.pb.h"
25#include "modules/common_msgs/sensor_msgs/sensor_image.pb.h"
26#include "modules/perception/camera_detection_occupancy/proto/camera_detection_occupancy.pb.h"
27
28#include "cyber/cyber.h"
33
34namespace apollo {
35namespace perception {
36namespace camera {
37
39 public:
42
43 public:
44 CameraDetectionOccComponent() : timestamp_offset_(0) {}
51 bool Init() override;
52
53 private:
54 bool InitTransformWrapper(const CameraDetectionBEV& detection_param);
55 bool InitCameraFrame(const CameraDetectionBEV& detection_param);
56 bool InitListeners(const CameraDetectionBEV& detection_param);
57 bool InitDetector(const CameraDetectionBEV& detection_param);
58
59 bool OnReceiveImage(const std::shared_ptr<drivers::Image>& msg);
60
61 void CameraToWorldCoor(const Eigen::Affine3d& camera2world,
62 std::vector<base::ObjectPtr>* objs);
63 int ConvertObjectToPb(const base::ObjectPtr& object_ptr,
64 PerceptionObstacle* pb_msg);
65 int MakeProtobufMsg(double msg_timestamp, int seq_num,
66 const std::vector<base::ObjectPtr>& objects,
67 PerceptionObstacles* obstacles);
68 bool LoadCameraExtrinsic(const std::string& file_path,
69 Eigen::Affine3d* camera_extrinsic);
70 bool LoadCameraExtrinsicNus(
71 const std::string &camera_extrinsic_file_path,
72 const std::string &lidar_extrinsic_file_path,
73 Eigen::Affine3d *camera2lidar_rt);
74 bool ConvertToBaseFrame(const CameraFrame* frame, base::Frame* base_frame);
75
76 private:
77 int image_height_;
78 int image_width_;
79 uint32_t seq_num_ = 0;
80 double timestamp_offset_ = 0;
81 ObstacleDetectorInitOptions init_options;
82 TrackerInitOptions tracker_init_options;
83
84 std::shared_ptr<CameraFrame> frame_ptr_;
85 std::shared_ptr<base::Frame> base_frame_ptr_;
86 std::shared_ptr<BaseObstacleDetector> detector_;
87 std::shared_ptr<BaseTracker> tracker_;
88 // ObjectBuilder builder_;
89 std::shared_ptr<onboard::TransformWrapper> trans_wrapper_;
90
91 std::vector<std::shared_ptr<cyber::Reader<drivers::Image>>> readers_;
92 std::shared_ptr<cyber::Writer<PerceptionObstacles>> writer_;
93};
94
96
97} // namespace camera
98} // namespace perception
99} // namespace apollo
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:656
std::shared_ptr< Object > ObjectPtr
Definition object.h:127
class register implement
Definition arena_queue.h:37