Apollo 11.0
自动驾驶开放平台
center_point_detection.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2022 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
17#pragma once
18
19#include <deque>
20#include <map>
21#include <memory>
22#include <string>
23#include <vector>
24
25#include "paddle/include/paddle_inference_api.h"
26#include "pcl/point_cloud.h"
27#include "pcl/point_types.h"
28
35#include "modules/perception/lidar_detection/detector/center_point_detection/proto/model_param.pb.h"
36
37namespace apollo {
38namespace perception {
39namespace lidar {
40
42 public:
48
53 virtual ~CenterPointDetection() = default;
54
62 bool Init(const LidarDetectorInitOptions &options =
63 LidarDetectorInitOptions()) override;
64
73 bool Detect(const LidarDetectorOptions &options, LidarFrame *frame) override;
74
80 std::string Name() const { return "CenterPointDetection"; }
81
82 private:
83 void CloudToArray(const base::PointFCloudPtr &pc_ptr, float *out_points_array,
84 float normalizing_factor);
85
86 void FuseCloud(const base::PointFCloudPtr &out_cloud_ptr,
87 const std::deque<base::PointDCloudPtr> &fuse_clouds);
88
89 bool Preprocess(const float *in_points_array, const int in_num_points,
90 std::vector<int> *voxels_shape,
91 std::vector<float> *voxels_data,
92 std::vector<int> *num_points_shape,
93 std::vector<int> *num_points_data,
94 std::vector<int> *coords_shape,
95 std::vector<int> *coords_data);
96
97 std::vector<int> GenerateIndices(int start_index, int size, bool shuffle);
98
99 void GetBoxCorner(int num_objects,
100 const std::vector<float> &detections,
101 std::vector<float> &box_corner,
102 std::vector<float> &box_rectangular);
103
104 void GetBoxIndices(int num_objects,
105 const std::vector<float> &detections,
106 const std::vector<float> &box_corner,
107 const std::vector<float> &box_rectangular,
108 std::vector<std::shared_ptr<base::Object>> *objects);
109
110 void GetObjects(const Eigen::Affine3d &pose,
111 const std::vector<float> &detections,
112 const std::vector<int64_t> &labels,
113 const std::vector<float> &scores,
114 std::vector<std::shared_ptr<base::Object>> *objects);
115
116 void FilterScore(
117 const std::shared_ptr<apollo::perception::base::Blob<float>> &box3d,
118 const std::shared_ptr<apollo::perception::base::Blob<float>> &label,
119 const std::shared_ptr<apollo::perception::base::Blob<float>> &scores,
120 float score_threshold, std::vector<float> *box3d_filtered,
121 std::vector<int64_t> *label_preds_filtered,
122 std::vector<float> *scores_filtered);
123
124 void FilterDiffScore(
125 const std::shared_ptr<apollo::perception::base::Blob<float>> &box3d,
126 const std::shared_ptr<apollo::perception::base::Blob<float>> &label,
127 const std::shared_ptr<apollo::perception::base::Blob<float>> &scores,
128 std::vector<float> *box3d_filtered,
129 std::vector<int64_t> *label_preds_filtered,
130 std::vector<float> *scores_filtered);
131
132 base::ObjectSubType GetObjectSubType(int label);
133
134 float GetObjectScoreThreshold(int label);
135
136 void FilterObjectsbyPoints(
137 std::vector<std::shared_ptr<base::Object>> *objects);
138
139 void FilterForegroundPoints(
140 std::vector<std::shared_ptr<base::Object>> *objects);
141
142 void SetPointsInROI(
143 std::vector<std::shared_ptr<base::Object>> *objects);
144
145 void FilterObjectsbyClassNMS(
146 std::vector<std::shared_ptr<base::Object>> *objects);
147
148 void FilterObjectsbySemanticType(
149 std::vector<std::shared_ptr<base::Object>> *objects);
150
151 // reference pointer of lidar frame
152 LidarFrame *lidar_frame_ref_ = nullptr;
153 std::shared_ptr<base::AttributePointCloud<base::PointF>> original_cloud_;
154 std::shared_ptr<base::AttributePointCloud<base::PointD>>
155 original_world_cloud_;
156
157 std::deque<base::PointDCloudPtr> prev_world_clouds_;
158
159 base::PointFCloudPtr cur_cloud_ptr_;
160
161 // point cloud range
162 float x_min_range_;
163 float x_max_range_;
164 float y_min_range_;
165 float y_max_range_;
166 float z_min_range_;
167 float z_max_range_;
168
169 // time statistics
170 double downsample_time_ = 0.0;
171 double fuse_time_ = 0.0;
172 double shuffle_time_ = 0.0;
173 double cloud_to_array_time_ = 0.0;
174 double inference_time_ = 0.0;
175 double collect_time_ = 0.0;
176 double postprocess_time_ = 0.0;
177 double nms_time_ = 0.0;
178
179 // diff class nms params
180 bool diff_class_nms_ = false;
181 float diff_class_iou_ = 0.0;
182 // true: use nms strategy, false: use nms by object score
183 bool nms_strategy_ = false;
184 std::map<base::ObjectType, std::vector<base::ObjectType>> nms_strategy_table_;
185
186 // centerpoint param
187 centerpoint::ModelParam model_param_;
188
189 // centerpoint type score threshold
190 float cone_score_threshold_ = 0.40;
191 float ped_score_threshold_ = 0.40;
192 float cyc_score_threshold_ = 0.40;
193 float small_mot_score_threshold_ = 0.40;
194 float big_mot_score_threshold_ = 0.40;
195
196 std::shared_ptr<inference::Inference> inference_;
197
198 std::vector<std::string> input_blob_names_;
199
200 std::vector<std::string> output_blob_names_;
201
202 std::shared_ptr<BaseDownSample> down_sample_;
203}; // class CenterPointDetection
204
205} // namespace lidar
206} // namespace perception
207} // namespace apollo
A wrapper around SyncedMemory holders serving as the basic computational unit for images,...
Definition blob.h:88
CenterPointDetection()
Construct a new Center Point Detection object
bool Init(const LidarDetectorInitOptions &options=LidarDetectorInitOptions()) override
Init of Center Point Detection module
virtual ~CenterPointDetection()=default
Destroy the Center Point Detection object
std::string Name() const
Name of Center Point Detection module
bool Detect(const LidarDetectorOptions &options, LidarFrame *frame) override
Detect foreground object using centerpoint
std::shared_ptr< PointFCloud > PointFCloudPtr
class register implement
Definition arena_queue.h:37