Apollo  6.0
Open source self driving car software
spp_engine.h
Go to the documentation of this file.
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 <string>
19 
20 #include "Eigen/Dense"
21 
28 
29 namespace apollo {
30 namespace perception {
31 namespace lidar {
32 
33 class SppEngine {
34  public:
35  SppEngine() = default;
36  ~SppEngine() = default;
37  // @brief: initialize spp engine
38  // @param [in]: feature map width
39  // @param [in]: feature map height
40  // @param [in]: feature map range
41  // @param [in]: sensor name
42  void Init(size_t width, size_t height, float range,
43  const SppParams& param = SppParams(),
44  const std::string& sensor_name = "velodyne64");
45  // @brief: process foreground segmentation
46  // @param [in]: point cloud
47  // @return: size of foreground clusters
49  const base::PointFCloudConstPtr point_cloud);
50  // @brief: remove ground points in foreground cluster
51  // @param [in]: point cloud
52  // @param [in]: roi indices of point cloud
53  // @param [in]: non ground indices in roi of point cloud
55  const base::PointFCloudConstPtr full_point_cloud,
56  const base::PointIndices& roi_indices,
57  const base::PointIndices& roi_non_ground_indices);
58  // @brief: get cluster list, const version
59  // @return: cluster list
60  inline const SppClusterList& clusters() const { return clusters_; }
61  // @brief: get cluster list, const version
62  // @return: cluster list
63  inline SppClusterList& clusters() { return clusters_; }
64  // @brief: get feature data, need to filled first
65  inline SppData& GetSppData() { return data_; }
66  // @brief: get feature data, need to filled first, const version
67  inline const SppData& GetSppData() const { return data_; }
68 
69  private:
70  // @brief: process clustering on input feature map
71  // @param [in]: point cloud
72  // @param [in]: point cloud mask
73  size_t ProcessConnectedComponentCluster(
74  const base::PointFCloudConstPtr point_cloud, const CloudMask& mask);
75 
76  private:
77  // feature size
78  size_t width_ = 0;
79  size_t height_ = 0;
80  float range_ = 0.f;
81  // label image
82  SppLabelImage labels_2d_;
83  // clusters
84  SppClusterList clusters_;
85  // cloud mask
86  CloudMask mask_;
87  CloudMask roi_mask_;
88  // clustering method
89  SppCCDetector detector_2d_cc_;
90  // global parameters
91  SppParams params_;
92  // const spp data pointer
93  SppData data_;
94  // thread worker for sync data
95  lib::ThreadWorker worker_;
96 };
97 
98 } // namespace lidar
99 } // namespace perception
100 } // namespace apollo
Definition: spp_seg_cc_2d.h:28
SppClusterList & clusters()
Definition: spp_engine.h:63
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: spp_struct.h:58
const SppData & GetSppData() const
Definition: spp_engine.h:67
Definition: spp_cluster_list.h:29
Definition: cloud_mask.h:26
void Init(size_t width, size_t height, float range, const SppParams &param=SppParams(), const std::string &sensor_name="velodyne64")
Definition: spp_struct.h:24
std::shared_ptr< const PointFCloud > PointFCloudConstPtr
Definition: point_cloud.h:483
const SppClusterList & clusters() const
Definition: spp_engine.h:60
size_t RemoveGroundPointsInForegroundCluster(const base::PointFCloudConstPtr full_point_cloud, const base::PointIndices &roi_indices, const base::PointIndices &roi_non_ground_indices)
Definition: spp_label_image.h:32
Definition: thread_worker.h:27
size_t ProcessForegroundSegmentation(const base::PointFCloudConstPtr point_cloud)
Definition: spp_engine.h:33
SppData & GetSppData()
Definition: spp_engine.h:65