Apollo 11.0
自动驾驶开放平台
cnn_segmentation.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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 "gtest/gtest_prod.h"
23
24#include "modules/perception/lidar_detection/detector/cnn_segmentation/proto/model_param.pb.h"
25
32
33namespace apollo {
34namespace perception {
35namespace lidar {
36
38 public:
43 CNNSegmentation() = default;
44
49 virtual ~CNNSegmentation() = default;
50
58 bool Init(const LidarDetectorInitOptions& options =
59 LidarDetectorInitOptions()) override;
60
69 bool Detect(const LidarDetectorOptions& options, LidarFrame* frame) override;
70
76 std::string Name() const override { return "CNNSegmentation"; }
77
78 private:
79 bool InitClusterAndBackgroundSegmentation();
80
81 void GetObjectsFromSppEngine(
82 std::vector<std::shared_ptr<base::Object>>* objects);
83
84 void MapPointToGrid(
85 const std::shared_ptr<base::AttributePointCloud<base::PointF>>& pc_ptr);
86
87 private:
88 cnnseg::ModelParam model_param_;
89 std::shared_ptr<inference::Inference> inference_;
90 std::shared_ptr<FeatureGenerator> feature_generator_;
91
92 // output blobs
93 std::shared_ptr<base::Blob<float>> instance_pt_blob_;
94 std::shared_ptr<base::Blob<float>> category_pt_blob_;
95 std::shared_ptr<base::Blob<float>> confidence_pt_blob_;
96 std::shared_ptr<base::Blob<float>> classify_pt_blob_;
97 std::shared_ptr<base::Blob<float>> heading_pt_blob_;
98 std::shared_ptr<base::Blob<float>> height_pt_blob_;
99 // input blobs
100 std::shared_ptr<base::Blob<float>> feature_blob_;
101
102 // feature parameters
103 float range_ = 0.f;
104 int width_ = 0;
105 int height_ = 0;
106 float min_height_ = 0.f;
107 float max_height_ = 0.f;
108
109 // 1-d index in feature map of each point
110 std::vector<int> point2grid_;
111
112 // spp engine
113 SppEngine spp_engine_;
114
115 // reference pointer of lidar frame
116 LidarFrame* lidar_frame_ref_ = nullptr;
117 std::shared_ptr<base::AttributePointCloud<base::PointF>> original_cloud_;
118 std::shared_ptr<base::AttributePointCloud<base::PointD>>
119 original_world_cloud_;
120 std::shared_ptr<base::AttributePointCloud<base::PointF>> roi_cloud_;
121 std::shared_ptr<base::AttributePointCloud<base::PointD>> roi_world_cloud_;
122 int gpu_id_ = -1;
123
124 // time statistics
125 double mapping_time_ = 0.0;
126 double feature_time_ = 0.0;
127 double infer_time_ = 0.0;
128 double fg_seg_time_ = 0.0;
129 double collect_time_ = 0.0;
130
131 // sensor_name
132 std::string sensor_name_;
133
134 private:
135 const int kDefaultPointCloudSize = 120000;
136
137 FRIEND_TEST(CNNSegmentationTest, cnn_segmentation_sequence_test);
138 FRIEND_TEST(CNNSegmentationTest, cnn_segmentation_test);
139}; // class CNNSegmentation
140
141} // namespace lidar
142} // namespace perception
143} // namespace apollo
virtual ~CNNSegmentation()=default
Destroy the CNNSegmentation object
std::string Name() const override
Name of CNNSegmentation module
bool Detect(const LidarDetectorOptions &options, LidarFrame *frame) override
Detect foreground objects using CNNSegmentation
CNNSegmentation()=default
Construct a new CNNSegmentation object
bool Init(const LidarDetectorInitOptions &options=LidarDetectorInitOptions()) override
Init of CNNSegmentation object
class register implement
Definition arena_queue.h:37