Apollo  6.0
Open source self driving car software
obstacle_reference.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 <map>
19 #include <string>
20 #include <vector>
21 
26 #include "modules/perception/camera/lib/obstacle/tracker/omt/proto/omt.pb.h"
28 
30 
31 namespace apollo {
32 namespace perception {
33 namespace camera {
34 
35 struct Reference {
36  float area = 0.0f;
37  float k = 0.0f;
38  float ymax = 0.0f;
39 };
40 
42  public:
43  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
44  void Init(const omt::ReferenceParam &ref_param, float width, float height);
45  void UpdateReference(const CameraFrame *frame,
46  const EigenVector<Target> &targets);
47  void CorrectSize(CameraFrame *frame);
48 
49  private:
50  void SyncGroundEstimator(const std::string &sensor,
51  const Eigen::Matrix3f &camera_k_matrix,
52  int img_width, int img_height) {
53  if (ground_estimator_mapper_.find(sensor) ==
54  ground_estimator_mapper_.end()) {
55  auto &ground_estimator = ground_estimator_mapper_[sensor];
56  const float fx = camera_k_matrix(0, 0);
57  const float fy = camera_k_matrix(1, 1);
58  const float cx = camera_k_matrix(0, 2);
59  const float cy = camera_k_matrix(1, 2);
60  std::vector<float> k_mat = {fx, 0, cx, 0, fy, cy, 0, 0, 1};
61  ground_estimator.Init(k_mat, img_width, img_height, common::IRec(fx));
62  }
63  }
64 
65  private:
66  omt::ReferenceParam ref_param_;
67  std::map<std::string, std::vector<Reference>> reference_;
68  std::map<std::string, std::vector<std::vector<int>>> ref_map_;
69  std::vector<std::vector<int>> init_ref_map_;
70  float img_width_;
71  float img_height_;
72  int ref_width_;
73  int ref_height_;
74 
75  // ground estimator W.R.T different cameras
76  std::map<std::string, CameraGroundPlaneDetector> ground_estimator_mapper_;
77 
78  protected:
79  ObjectTemplateManager *object_template_manager_ = nullptr;
80 };
81 } // namespace camera
82 } // namespace perception
83 } // namespace apollo
std::vector< EigenType, Eigen::aligned_allocator< EigenType > > EigenVector
Definition: eigen_defs.h:32
Definition: camera_frame.h:33
Definition: obstacle_reference.h:41
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
float ymax
Definition: obstacle_reference.h:38
float area
Definition: obstacle_reference.h:36
Eigen::Matrix3f Matrix3f
Definition: base_map_fwd.h:27
Definition: obstacle_reference.h:35
Definition: object_template_manager.h:49
bool Init(const char *binary_name)
float k
Definition: obstacle_reference.h:37