Apollo  v5.5.0
Open source self driving car software
roi_boundary_filter.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 #include <vector>
20 
21 #include "Eigen/Dense"
22 #include "gtest/gtest_prod.h"
23 
27 
28 namespace apollo {
29 namespace perception {
30 namespace lidar {
31 
33  public:
34  ROIBoundaryFilter() = default;
35 
36  virtual ~ROIBoundaryFilter() = default;
37 
38  bool Init(const ObjectFilterInitOptions& options =
39  ObjectFilterInitOptions()) override;
40 
41  // @brief: filter objects
42  // @param [in]: options
43  // @param [in/out]: frame
44  // segmented_objects should be valid, and will be filtered,
45  bool Filter(const ObjectFilterOptions& options, LidarFrame* frame) override;
46 
47  std::string Name() const override { return "ROIBoundaryFilter"; }
48 
49  private:
50  // @brief: given input objects, build polygon in world frame
51  void BuildWorldPolygons(const ObjectFilterOptions& options,
52  const LidarFrame& frame);
53  // @brief: fill is_in_roi in lidar object supplement
54  void FillObjectRoiFlag(const ObjectFilterOptions& options, LidarFrame* frame);
55  // @brief: filter outside objects based on distance to boundary
56  void FilterObjectsOutsideBoundary(const ObjectFilterOptions& options,
57  LidarFrame* frame,
58  std::vector<bool>* objects_valid_flag);
59  // @brief: filter inside objects based on distance to boundary
60  void FilterObjectsInsideBoundary(const ObjectFilterOptions& options,
61  LidarFrame* frame,
62  std::vector<bool>* objects_valid_flag);
63  // @brief: filter objects based on position and confidence
64  void FilterObjectsByConfidence(const ObjectFilterOptions& options,
65  LidarFrame* frame,
66  std::vector<bool>* objects_valid_flag);
67 
68  private:
69  FRIEND_TEST(ROIBoundaryFilterTest, roi_boundary_filter_test);
70 
71  std::vector<perception::base::AttributePointCloud<perception::base::PointD>>
72  polygons_in_world_;
73  std::vector<bool> objects_cross_roi_;
74  std::vector<bool> objects_valid_flag_;
75  // params
76  double distance_to_boundary_threshold_ = 1.0;
77  double inside_threshold_ = 1.0;
78  float confidence_threshold_ = 0.5f;
79  float cross_roi_threshold_ = 0.6f;
80 }; // class ROIBoundaryFilter
81 
82 } // namespace lidar
83 } // namespace perception
84 } // namespace apollo
Definition: roi_boundary_filter.h:32
Definition: blob.h:72
bool Filter(const ObjectFilterOptions &options, LidarFrame *frame) override
Definition: base_object_filter.h:34
Definition: base_object_filter.h:28
bool Init(const ObjectFilterInitOptions &options=ObjectFilterInitOptions()) override
Definition: lidar_frame.h:33
std::string Name() const override
Definition: roi_boundary_filter.h:47
Definition: base_object_filter.h:32