Apollo 11.0
自动驾驶开放平台
cloud_mask.cc
浏览该文件的文档.
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 *****************************************************************************/
17
18namespace apollo {
19namespace perception {
20namespace lidar {
21
22using base::AttributePointCloud;
23using base::PointF;
24
26 size_t count = 0;
27 for (auto& i : mask_) {
28 if (i > 0) {
29 ++count;
30 }
31 }
32 return count;
33}
34
36 AttributePointCloud<PointF>* target_cloud) const {
37 if (target_cloud == nullptr) {
38 return;
39 }
40 indices_.clear();
41 indices_.reserve(mask_.size());
42 for (size_t i = 0; i < mask_.size(); ++i) {
43 if (mask_[i] > 0) {
44 indices_.push_back(static_cast<int>(i));
45 }
46 }
47 target_cloud->CopyPointCloud(source_cloud, indices_);
48}
49
51 indices->indices.clear();
52 indices->indices.reserve(mask_.size());
53 for (size_t i = 0; i < mask_.size(); ++i) {
54 if (mask_[i] > 0) {
55 indices->indices.push_back(static_cast<int>(i));
56 }
57 }
58}
59
61 for (auto& i : mask_) {
62 i = i > 0 ? 0 : 1;
63 }
64}
65
66void CloudMask::AddIndices(const base::PointIndices& indices, int value) {
67 AddIndices(indices.indices, value);
68}
69
71 const base::PointIndices& indices,
72 const base::PointIndices& indices_of_indices, int value) {
73 for (auto& id : indices_of_indices.indices) {
74 mask_[indices.indices[id]] = value;
75 }
76}
77
79 RemoveIndices(indices.indices);
80}
81
83 const base::PointIndices& indices,
84 const base::PointIndices& indices_of_indices) {
85 for (auto& id : indices_of_indices.indices) {
86 mask_[indices.indices[id]] = 0;
87 }
88}
89
91 if (rhs == nullptr) {
92 return;
93 }
94 rhs->clear();
95 for (const auto& i : mask_) {
96 if (i > 0) {
97 rhs->mask_.push_back(i);
98 }
99 }
100}
101
102void CloudMask::ResetValue(int source_value, int target_value) {
103 for (auto& i : mask_) {
104 if (i == source_value) {
105 i = target_value;
106 }
107 }
108}
109
110} // namespace lidar
111} // namespace perception
112} // namespace apollo
void CopyPointCloud(const AttributePointCloud< PointT > &rhs, const PointIndices &indices)
void RemoveIndices(const base::PointIndices &indices)
Definition cloud_mask.cc:78
void ResetValue(int source_value, int target_value)
void AddIndices(const base::PointIndices &indices, int value=1)
Definition cloud_mask.cc:66
void GetValidCloud(const base::AttributePointCloud< base::PointF > &source_cloud, base::AttributePointCloud< base::PointF > *target_cloud) const
Definition cloud_mask.cc:35
std::vector< int > GetValidIndices()
void AddIndicesOfIndices(const base::PointIndices &indices, const base::PointIndices &indices_of_indices, int value=1)
Definition cloud_mask.cc:70
void RemoveIndicesOfIndices(const base::PointIndices &indices, const base::PointIndices &indices_of_indices)
Definition cloud_mask.cc:82
void GetValidMask(CloudMask *rhs) const
Definition cloud_mask.cc:90
Point< float > PointF
Definition point.h:56
class register implement
Definition arena_queue.h:37