Apollo  6.0
Open source self driving car software
location_refiner_obstacle_postprocessor.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 
22 #include "modules/perception/camera/lib/obstacle/postprocessor/location_refiner/proto/location_refiner.pb.h"
23 
24 namespace apollo {
25 namespace perception {
26 namespace camera {
27 
29  public:
31  postprocessor_ = new ObjPostProcessor;
32  }
33 
35  delete postprocessor_;
36  postprocessor_ = nullptr;
37  }
38  bool Init(const ObstaclePostprocessorInitOptions &options =
40 
41  // @brief: post-refine location of 3D obstacles
42  // @param [in]: frame
43  // @param [out]: frame
44  bool Process(const ObstaclePostprocessorOptions &options,
45  CameraFrame *frame) override;
46 
47  std::string Name() const override;
48 
49  private:
50  bool is_in_roi(const float pt[2], float img_w, float img_h, float v,
51  float h_down) const {
52  float x = pt[0];
53  float y = pt[1];
54  if (y < v) {
55  return false;
56  } else if (y > (img_h - h_down)) {
57  return true;
58  }
59  float img_w_half = img_w / 2.0f;
60  float slope = img_w_half * common::IRec(img_h - h_down - v);
61  float left = img_w_half - slope * (y - v);
62  float right = img_w_half + slope * (y - h_down);
63  return x > left && x < right;
64  }
65 
66  private:
67  // int image_width_ = 0;
68  // int image_height_ = 0;
69  ObjPostProcessor *postprocessor_ = nullptr;
70  location_refiner::LocationRefinerParam location_refiner_param_;
71 };
72 
73 } // namespace camera
74 } // namespace perception
75 } // namespace apollo
virtual ~LocationRefinerObstaclePostprocessor()
Definition: location_refiner_obstacle_postprocessor.h:34
Definition: camera_frame.h:33
Definition: location_refiner_obstacle_postprocessor.h:28
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
float IRec(float a)
Definition: i_basic.h:69
bool Init(const ObstaclePostprocessorInitOptions &options=ObstaclePostprocessorInitOptions()) override
Definition: obj_postprocessor.h:62
Definition: base_obstacle_postprocessor.h:36
LocationRefinerObstaclePostprocessor()
Definition: location_refiner_obstacle_postprocessor.h:30
bool Process(const ObstaclePostprocessorOptions &options, CameraFrame *frame) override
Definition: base_obstacle_postprocessor.h:29
Definition: base_obstacle_postprocessor.h:31