Apollo  6.0
Open source self driving car software
obj_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 <vector>
19 
20 #ifdef LOCAL_REPO
21 // local repo header path
22 #include "modules/perception/common/noncopyable.h"
23 #include "modules/perception/lib/common/twod_threed_util.h"
24 #else
25 // perception-camera header path
27 #endif
28 
29 namespace apollo {
30 namespace perception {
31 namespace camera {
32 
34  // ground + line segments
35  float plane[4] = {0};
36  std::vector<LineSegment2D<float>> line_segs = {};
37  bool check_lowerbound = true;
38 
39  // disparity
40  float *disp_map = nullptr;
41  float baseline = 0.0f;
42 
43  float hwl[3] = {0};
44  float bbox[4] = {0};
45  float ry = 0.0f;
46 };
47 
48 // hyper parameters
50  ObjPostProcessorParams() { set_default(); }
51  void set_default();
54  float weight_iou;
55  float learning_r;
57  float dist_far;
59  float iou_good;
60 };
61 
63  public:
66 
67  void Init(const float *k_mat, int width, int height) {
68  memcpy(k_mat_, k_mat, sizeof(float) * 9);
69  width_ = width;
70  height_ = height;
71  }
72 
73  bool PostProcessObjWithGround(const ObjPostProcessorOptions &options,
74  float center[3], float hwl[3], float *ry);
75 
76  bool PostProcessObjWithDispmap(const ObjPostProcessorOptions &options,
77  float center[3], float hwl[3], float *ry);
78 
79  private:
80  float GetProjectionScore(float ry, const float *bbox, const float *hwl,
81  const float *center,
82  const bool &check_truncation = true) const {
83  float rot[9] = {0};
84  GenRotMatrix(ry, rot);
85  float *bbox_null_1 = nullptr;
86  float *bbox_null_2 = nullptr;
87  return GetScoreViaRotDimensionCenter(&k_mat_[0], width_, height_, bbox, rot,
88  hwl, center, check_truncation,
89  bbox_null_1, bbox_null_2);
90  }
91 
92  // refinement using ground-3d bbox consistency
93  bool AdjustCenterWithGround(const float *bbox, const float *hwl, float ry,
94  const float *plane, float *center) const;
95 
96  // adjustment using on-ground line segments
97  bool PostRefineCenterWithGroundBoundary(
98  const float *bbox, const float *hwl, float ry, const float *plane,
99  const std::vector<LineSegment2D<float>> &line_seg_limits, float *center,
100  bool check_lowerbound) const;
101 
102  int GetDepthXPair(const float *bbox, const float *hwl, const float *center,
103  float ry, float *depth_pts, int *x_pts,
104  float *pts_c = nullptr) const;
105 
106  private:
107  float k_mat_[9] = {0};
108  int width_ = 0;
109  int height_ = 0;
110  ObjPostProcessorParams params_;
111  // DISALLOW_COPY_AND_ASSIGN(ObjPostProcessor);
112 };
113 
114 } // namespace camera
115 } // namespace perception
116 } // namespace apollo
Definition: obj_postprocessor.h:33
float weight_iou
Definition: obj_postprocessor.h:54
float bbox[4]
Definition: obj_postprocessor.h:44
float iou_good
Definition: obj_postprocessor.h:59
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
float plane[4]
Definition: obj_postprocessor.h:35
float * disp_map
Definition: obj_postprocessor.h:40
Definition: obj_postprocessor.h:62
float learning_r_decay
Definition: obj_postprocessor.h:56
void GenRotMatrix(const T &ry, T *rot)
Definition: twod_threed_util.h:101
int max_nr_iter
Definition: obj_postprocessor.h:52
std::vector< LineSegment2D< float > > line_segs
Definition: obj_postprocessor.h:36
float hwl[3]
Definition: obj_postprocessor.h:43
~ObjPostProcessor()
Definition: obj_postprocessor.h:65
float ry
Definition: obj_postprocessor.h:45
Definition: twod_threed_util.h:33
float dist_far
Definition: obj_postprocessor.h:57
ObjPostProcessor()
Definition: obj_postprocessor.h:64
ObjPostProcessorParams()
Definition: obj_postprocessor.h:50
T GetScoreViaRotDimensionCenter(const T *k_mat, int width, int height, const T *bbox, const T *rot, const T *hwl, const T *location, const bool &check_truncation, T *bbox_res=nullptr, T *bbox_near=nullptr)
Definition: twod_threed_util.h:177
float baseline
Definition: obj_postprocessor.h:41
Definition: obj_postprocessor.h:49
float shrink_ratio_iou
Definition: obj_postprocessor.h:58
float learning_r
Definition: obj_postprocessor.h:55
bool check_lowerbound
Definition: obj_postprocessor.h:37
void Init(const float *k_mat, int width, int height)
Definition: obj_postprocessor.h:67
float sampling_ratio_low
Definition: obj_postprocessor.h:53