Apollo 11.0
自动驾驶开放平台
spp_cluster_list.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 <string>
19#include <vector>
20
21#include "cyber/common/macros.h"
24
25namespace apollo {
26namespace perception {
27namespace lidar {
28
30 public:
31 SppClusterList() { clusters_.reserve(kDefaultReserveSize); }
32 // @brief: initialize cluster list
33 // @param [in]: size
34 // @param [in]: sensor_name
35 void Init(size_t size, const std::string& sensor_name = "velodyne64");
36 // @brief: reset cluster list
37 inline void Reset() { clusters_.clear(); }
38 // @brief: resize cluster list
39 // @param [in]: size
40 void resize(size_t size);
41 // @brief: add an 3d point sample
42 // @param [in]: cluster id
43 // @param [in]: 3d point
44 // @param [in]: point height above ground
45 // @param [in]: point id
46 void AddPointSample(size_t cluster_id, const base::PointF& point,
47 float height, uint32_t point_id);
48 // @brief: get clusters data
49 // @return: clusters
50 inline std::vector<SppClusterPtr>& clusters() { return clusters_; }
51 // @brief: get clusters data, const version
52 // @return: clusters
53 inline const std::vector<SppClusterPtr>& clusters() const {
54 return clusters_;
55 }
56 // @brief: get clusters size
57 // @return: cluster size
58 inline size_t size() const { return clusters_.size(); }
59 // @brief: get cluster pointer
60 // @return: cluster pointer
61 inline SppClusterPtr& operator[](int id) { return clusters_[id]; }
62 // @brief: get cluster pointer, const version
63 // @return: cluster pointer
64 inline const SppClusterPtr& operator[](int id) const { return clusters_[id]; }
65 // @brief: merge elements from another cluster list and clear it
66 // @param [in]: another cluster list
67 void Merge(SppClusterList* rhs);
68 // @brief: cut along height axis to split cluster
69 // @param [in]: max gap value in two connected component
70 // @param [in]: start cluster id
71 // @return: cut number in all clusters
72 size_t HeightCut(float max_gap, size_t start_id = 0);
73 // @brief: compute height and split clusters
74 // @param [in]: cluster id
75 // @param [in]: max gap value in two connected component
76 // @return: true if successfully split
77 bool ComputeHeightAndSplitCluster(size_t id, float max_gap);
78 // @brief: remove empty cluster from clusters
80 // @brief: remove cluster given id
81 void EraseCluster(size_t id);
82 // @brief: assign clusters from label image
84 clusters_ = rhs.GetClusters();
85 return *this;
86 }
87
88 private:
89 static const size_t kDefaultReserveSize = 500;
90
91 private:
92 std::vector<SppClusterPtr> clusters_;
93 std::string sensor_name_;
95};
96
97} // namespace lidar
98} // namespace perception
99} // namespace apollo
size_t HeightCut(float max_gap, size_t start_id=0)
void AddPointSample(size_t cluster_id, const base::PointF &point, float height, uint32_t point_id)
SppClusterList & operator=(const SppLabelImage &rhs)
const SppClusterPtr & operator[](int id) const
std::vector< SppClusterPtr > & clusters()
bool ComputeHeightAndSplitCluster(size_t id, float max_gap)
const std::vector< SppClusterPtr > & clusters() const
void Init(size_t size, const std::string &sensor_name="velodyne64")
std::vector< SppClusterPtr > & GetClusters()
#define DISALLOW_COPY_AND_ASSIGN(classname)
Definition macros.h:48
std::shared_ptr< SppCluster > SppClusterPtr
class register implement
Definition arena_queue.h:37