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