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

#include <point_pillars.h>

apollo::perception::lidar::PointPillars 的协作图:

Public 成员函数

 PointPillars (const bool reproduce_result_mode, const float score_threshold, const float nms_overlap_threshold, const common::Framework &model_type, const std::string &model_file)
 Constructor
 
 ~PointPillars ()
 Destroy the Point Pillars object
 
void DoInference (const float *in_points_array, const int in_num_points, std::vector< float > *out_detections, std::vector< int > *out_labels)
 Call PointPillars for the inference
 

友元

class TestClass
 

详细描述

在文件 point_pillars.h 第 116 行定义.

构造及析构函数说明

◆ PointPillars()

apollo::perception::lidar::PointPillars::PointPillars ( const bool  reproduce_result_mode,
const float  score_threshold,
const float  nms_overlap_threshold,
const common::Framework &  model_type,
const std::string &  model_file 
)

Constructor

参数
[in]reproduce_result_modeBoolean, if true, the output is reproducible for the same input
[in]score_thresholdScore threshold for filtering output
[in]nms_overlap_thresholdIOU threshold for NMS
[in]model_typePillar Model type
[in]model_filePillar Model file path

Variables could be changed through point_pillars_detection

在文件 point_pillars.cc 第 102 行定义.

107 : reproduce_result_mode_(reproduce_result_mode),
108 score_threshold_(score_threshold),
109 nms_overlap_threshold_(nms_overlap_threshold),
110 model_type_(model_type),
111 model_file_(model_file) {
112 if (reproduce_result_mode_) {
113 preprocess_points_ptr_.reset(new PreprocessPoints(
114 kMaxNumPillars, kMaxNumPointsPerPillar, kNumPointFeature, kGridXSize,
115 kGridYSize, kGridZSize, kPillarXSize, kPillarYSize, kPillarZSize,
116 kMinXRange, kMinYRange, kMinZRange, kNumIndsForScan));
117 } else {
118 preprocess_points_cuda_ptr_.reset(new PreprocessPointsCuda(
119 kNumThreads, kMaxNumPillars, kMaxNumPointsPerPillar, kNumPointFeature,
120 kNumIndsForScan, kGridXSize, kGridYSize, kGridZSize, kPillarXSize,
121 kPillarYSize, kPillarZSize, kMinXRange, kMinYRange, kMinZRange));
122 }
123
124 anchor_mask_cuda_ptr_.reset(new AnchorMaskCuda(
125 kNumThreads, kNumIndsForScan, kNumAnchor, kMinXRange, kMinYRange,
126 kPillarXSize, kPillarYSize, kGridXSize, kGridYSize));
127
128 const float float_min = std::numeric_limits<float>::lowest();
129 const float float_max = std::numeric_limits<float>::max();
130 postprocess_cuda_ptr_.reset(
131 new PostprocessCuda(float_min, float_max, kNumAnchor, kNumClass,
132 score_threshold_, kNumThreads, nms_overlap_threshold_,
133 kNumBoxCorners, kNumOutputBoxFeature));
134
135 DeviceMemoryMalloc();
136 InitTorch();
137 InitAnchors();
138}

◆ ~PointPillars()

apollo::perception::lidar::PointPillars::~PointPillars ( )

Destroy the Point Pillars object

在文件 point_pillars.cc 第 140 行定义.

140 {
141 delete[] anchors_px_;
142 delete[] anchors_py_;
143 delete[] anchors_pz_;
144 delete[] anchors_dx_;
145 delete[] anchors_dy_;
146 delete[] anchors_dz_;
147 delete[] anchors_ro_;
148 delete[] box_anchors_min_x_;
149 delete[] box_anchors_min_y_;
150 delete[] box_anchors_max_x_;
151 delete[] box_anchors_max_y_;
152
153 GPU_CHECK(cudaFree(dev_x_coors_));
154 GPU_CHECK(cudaFree(dev_y_coors_));
155 GPU_CHECK(cudaFree(dev_num_points_per_pillar_));
156 GPU_CHECK(cudaFree(dev_sparse_pillar_map_));
157 GPU_CHECK(cudaFree(dev_pillar_point_feature_));
158 GPU_CHECK(cudaFree(dev_pillar_coors_));
159
160 GPU_CHECK(cudaFree(dev_cumsum_along_x_));
161 GPU_CHECK(cudaFree(dev_cumsum_along_y_));
162
163 GPU_CHECK(cudaFree(dev_box_anchors_min_x_));
164 GPU_CHECK(cudaFree(dev_box_anchors_min_y_));
165 GPU_CHECK(cudaFree(dev_box_anchors_max_x_));
166 GPU_CHECK(cudaFree(dev_box_anchors_max_y_));
167 GPU_CHECK(cudaFree(dev_anchor_mask_));
168
169 GPU_CHECK(cudaFree(pfe_buffers_[0]));
170 GPU_CHECK(cudaFree(pfe_buffers_[1]));
171 GPU_CHECK(cudaFree(pfe_buffers_[2]));
172
173 GPU_CHECK(cudaFree(rpn_buffers_[0]));
174 GPU_CHECK(cudaFree(rpn_buffers_[1]));
175 GPU_CHECK(cudaFree(rpn_buffers_[2]));
176 GPU_CHECK(cudaFree(rpn_buffers_[3]));
177
178 GPU_CHECK(cudaFree(dev_scattered_feature_));
179
180 GPU_CHECK(cudaFree(dev_anchors_px_));
181 GPU_CHECK(cudaFree(dev_anchors_py_));
182 GPU_CHECK(cudaFree(dev_anchors_pz_));
183 GPU_CHECK(cudaFree(dev_anchors_dx_));
184 GPU_CHECK(cudaFree(dev_anchors_dy_));
185 GPU_CHECK(cudaFree(dev_anchors_dz_));
186 GPU_CHECK(cudaFree(dev_anchors_ro_));
187 GPU_CHECK(cudaFree(dev_filtered_box_));
188 GPU_CHECK(cudaFree(dev_filtered_score_));
189 GPU_CHECK(cudaFree(dev_filtered_label_));
190 GPU_CHECK(cudaFree(dev_filtered_dir_));
191 GPU_CHECK(cudaFree(dev_box_for_nms_));
192 GPU_CHECK(cudaFree(dev_filter_count_));
193}
#define GPU_CHECK(ans)

成员函数说明

◆ DoInference()

void apollo::perception::lidar::PointPillars::DoInference ( const float *  in_points_array,
const int  in_num_points,
std::vector< float > *  out_detections,
std::vector< int > *  out_labels 
)

Call PointPillars for the inference

参数
[in]in_points_arrayPoint cloud array
[in]in_num_pointsNumber of points
[out]out_detectionsNetwork output bounding box
[out]out_labelsNetwork output object's label

This is an interface for the algorithm

在文件 point_pillars.cc 第 624 行定义.

627 {
628 if (device_id_ < 0) {
629 AERROR << "Torch is not using GPU!";
630 return;
631 }
632
633 Preprocess(in_points_array, in_num_points);
634
635 anchor_mask_cuda_ptr_->DoAnchorMaskCuda(
636 dev_sparse_pillar_map_, dev_cumsum_along_x_, dev_cumsum_along_y_,
637 dev_box_anchors_min_x_, dev_box_anchors_min_y_, dev_box_anchors_max_x_,
638 dev_box_anchors_max_y_, dev_anchor_mask_);
639
640 // put input data to inferece_ blob
641 auto pillar_point_feature = inference_->get_blob(input_blob_names_.at(0));
642 auto points_per_pillar = inference_->get_blob(input_blob_names_.at(1));
643 auto pillar_coors = inference_->get_blob(input_blob_names_.at(2));
644 cudaStream_t stream;
645 GPU_CHECK(cudaStreamCreate(&stream));
646 GPU_CHECK(cudaMemcpyAsync(pillar_point_feature->mutable_gpu_data(),
647 dev_pillar_point_feature_,
648 kMaxNumPillars * kMaxNumPointsPerPillar *
649 kNumPointFeature * sizeof(float),
650 cudaMemcpyDeviceToDevice, stream));
651 GPU_CHECK(cudaMemcpyAsync(points_per_pillar->mutable_gpu_data(),
652 dev_num_points_per_pillar_,
653 kMaxNumPillars * sizeof(float),
654 cudaMemcpyDeviceToDevice, stream));
655 GPU_CHECK(cudaMemcpyAsync(pillar_coors->mutable_gpu_data(),
656 dev_pillar_coors_,
657 kMaxNumPillars * 4 * sizeof(float),
658 cudaMemcpyDeviceToDevice, stream));
659 inference_->Infer();
660
661 auto cls_score = inference_->get_blob(output_blob_names_.at(0));
662 auto bbox_pred = inference_->get_blob(output_blob_names_.at(1));
663 auto dir_cls_preds = inference_->get_blob(output_blob_names_.at(2));
664
665 GPU_CHECK(cudaMemset(dev_filter_count_, 0, sizeof(int)));
666 postprocess_cuda_ptr_->DoPostprocessCuda(
667 bbox_pred->gpu_data(),
668 cls_score->gpu_data(),
669 dir_cls_preds->gpu_data(),
670 dev_anchor_mask_, dev_anchors_px_, dev_anchors_py_, dev_anchors_pz_,
671 dev_anchors_dx_, dev_anchors_dy_, dev_anchors_dz_, dev_anchors_ro_,
672 dev_filtered_box_, dev_filtered_score_, dev_filtered_label_,
673 dev_filtered_dir_, dev_box_for_nms_, dev_filter_count_, out_detections,
674 out_labels);
675
676 // release the stream and the buffers
677 cudaStreamDestroy(stream);
678}
#define AERROR
Definition log.h:44

友元及相关函数文档

◆ TestClass

friend class TestClass
friend

在文件 point_pillars.h 第 118 行定义.


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