Apollo 11.0
自动驾驶开放平台
ncut_segmentation.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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#ifdef DEBUG_NCUT
23#include "pcl/visualization/pcl_visualizer.h"
24#endif
25
26#include "modules/perception/lidar_segmentation/segmentor/ncut_segmentation/proto/ncut_param.pb.h"
27
32
33namespace apollo {
34namespace perception {
35namespace lidar {
36
38public:
39 NCutSegmentation() = default;
40 virtual ~NCutSegmentation(){};
48 bool Init(const LidarDetectorInitOptions& options = LidarDetectorInitOptions()) override;
57 bool Detect(const LidarDetectorOptions& options, LidarFrame* frame) override;
63 std::string Name() const override {
64 return "NCutSegmentation";
65 }
71 remove_roi_ = false;
72 remove_ground_ = false;
73 }
74
75private:
76 bool Configure(std::string model_name);
77
78 void PartitionConnectedComponents(
79 const base::PointFCloudPtr& in_cloud,
80 float cell_size,
81 std::vector<base::PointFCloudPtr>* out_clouds);
82
83 void ObstacleFilter(
84 const base::PointFCloudPtr& in_cloud,
85 float cell_size,
86 bool filter_pedestrian_only,
87 base::PointFCloudPtr* out_cloud,
88 std::vector<base::ObjectPtr>* segments);
89
90 bool IsOutlier(const base::PointFCloudPtr& in_cloud);
91
92 base::ObjectType Label2Type(const std::string& label);
93
94 // reference pointer of lidar frame
95 LidarFrame* lidar_frame_ref_ = nullptr;
96 std::shared_ptr<base::AttributePointCloud<base::PointF>> original_cloud_;
97 std::shared_ptr<base::AttributePointCloud<base::PointD>> original_world_cloud_;
98 std::shared_ptr<base::AttributePointCloud<base::PointF>> roi_cloud_;
99 std::shared_ptr<base::AttributePointCloud<base::PointD>> roi_world_cloud_;
100
101 std::vector<std::shared_ptr<NCut>> _segmentors;
102 // for outliers, must be "unknown"
103 std::unique_ptr<std::vector<base::ObjectPtr>> _outliers;
104 float grid_radius_ = 100.0f;
105 float height_threshold_ = 2.5f;
106 float partition_cell_size_ = 1.0f;
107 float vehicle_filter_cell_size_ = 1.0f;
108 float pedestrian_filter_cell_size_ = 0.05f;
109 float outlier_length_ = 0.3f;
110 float outlier_width_ = 0.3f;
111 float outlier_height_ = 0.3f;
112 int outlier_min_num_points_ = 10;
113 bool remove_ground_ = false;
114 bool remove_roi_ = false;
115 bool filter_vehicle_ = false;
116 bool filter_pedestrian_ = false;
117 bool do_classification_ = true;
118 int num_threads_ = 1;
119 NCutParam ncut_param_;
120
121#ifdef DEBUG_NCUT
122 pcl::visualization::PCLVisualizer::Ptr _viewer;
123 CPointCloudPtr _rgb_cloud;
124 char _viewer_id[128];
125 int _viewer_count;
126 void VisualizePointCloud(const base::PointFCloudPtr& cloud);
127 void VisualizeSegments(const std::vector<base::ObjectPtr>& segments);
128 void VisualizeComponents(const base::PointFCloudPtr& cloud, const std::vector<std::vector<int>>& component_points);
129#endif
130}; // class NCutSegmentation
131
132} // namespace lidar
133} // namespace perception
134} // namespace apollo
bool Init(const LidarDetectorInitOptions &options=LidarDetectorInitOptions()) override
Init ncut segmentation
void ByPassROIService()
Reset roi and ground flag false
std::string Name() const override
Get class name
bool Detect(const LidarDetectorOptions &options, LidarFrame *frame) override
Detection function of ncut
std::shared_ptr< PointFCloud > PointFCloudPtr
pcl::PointCloud< CPoint >::Ptr CPointCloudPtr
Definition pcl_util.h:34
class register implement
Definition arena_queue.h:37