Apollo  6.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 
28 
29 namespace apollo {
30 namespace perception {
31 namespace lidar {
32 
34  public:
35  ROIBoundaryFilter() = default;
36 
37  virtual ~ROIBoundaryFilter() = default;
38 
39  bool Init(const ObjectFilterInitOptions& options =
40  ObjectFilterInitOptions()) override;
41 
42  // @brief: filter objects
43  // @param [in]: options
44  // @param [in/out]: frame
45  // segmented_objects should be valid, and will be filtered,
46  bool Filter(const ObjectFilterOptions& options, LidarFrame* frame) override;
47 
48  std::string Name() const override { return "ROIBoundaryFilter"; }
49 
50  private:
51  // @brief: given input objects, build polygon in world frame
52  void BuildWorldPolygons(const ObjectFilterOptions& options,
53  const LidarFrame& frame);
54  // @brief: fill is_in_roi in lidar object supplement
55  void FillObjectRoiFlag(const ObjectFilterOptions& options, LidarFrame* frame);
56  // @brief: filter outside objects based on distance to boundary
57  void FilterObjectsOutsideBoundary(const ObjectFilterOptions& options,
58  LidarFrame* frame,
59  std::vector<bool>* objects_valid_flag);
60  // @brief: filter inside objects based on distance to boundary
61  void FilterObjectsInsideBoundary(const ObjectFilterOptions& options,
62  LidarFrame* frame,
63  std::vector<bool>* objects_valid_flag);
64  // @brief: filter objects based on position and confidence
65  void FilterObjectsByConfidence(const ObjectFilterOptions& options,
66  LidarFrame* frame,
67  std::vector<bool>* objects_valid_flag);
68 
69  private:
70  FRIEND_TEST(ROIBoundaryFilterTest, roi_boundary_filter_test);
71 
73  polygons_in_world_;
74  std::vector<bool> objects_cross_roi_;
75  std::vector<bool> objects_valid_flag_;
76  // params
77  double distance_to_boundary_threshold_ = 1.0;
78  double inside_threshold_ = 1.0;
79  float confidence_threshold_ = 0.5f;
80  float cross_roi_threshold_ = 0.6f;
81 }; // class ROIBoundaryFilter
82 
83 } // namespace lidar
84 } // namespace perception
85 } // namespace apollo
std::vector< EigenType, Eigen::aligned_allocator< EigenType > > EigenVector
Definition: eigen_defs.h:32
Definition: roi_boundary_filter.h:33
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
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:48
Definition: base_object_filter.h:32