Apollo  6.0
Open source self driving car software
distortion_model.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 <memory>
19 #include <string>
20 
22 
23 namespace apollo {
24 namespace perception {
25 namespace base {
26 
28  public:
29  BaseCameraDistortionModel() = default;
30  virtual ~BaseCameraDistortionModel() = default;
31 
32  // @brief: project a point from camera space to image plane
33  // @params[IN] point3d: 3d point in camera space;
34  // @return: 2d point in image plane
35  // @note: the input point should be in front of the camera,
36  // i.e. point3d[2] > 0
37  virtual Eigen::Vector2f Project(const Eigen::Vector3f& point3d) = 0;
38 
39  virtual std::shared_ptr<BaseCameraModel> get_camera_model() = 0;
40  virtual std::string name() const = 0;
41  virtual bool set_params(size_t width, size_t height,
42  const Eigen::VectorXf& params) = 0;
43 
44  size_t get_height() const { return height_; }
45  size_t get_width() const { return width_; }
46 
47  protected:
48  size_t width_ = 0;
49  size_t height_ = 0;
50 };
51 
52 /* TODO(all): to remove
53 typedef std::shared_ptr<BaseCameraDistortionModel> BaseCameraDistortionModelPtr;
54 typedef std::shared_ptr<const BaseCameraDistortionModel>
55  BaseCameraDistortionModelConstPtr;
56 */
57 
59  public:
60  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
61 
62  public:
63  BrownCameraDistortionModel() = default;
64  ~BrownCameraDistortionModel() = default;
65 
66  Eigen::Vector2f Project(const Eigen::Vector3f& point3d) override;
67 
68  std::shared_ptr<BaseCameraModel> get_camera_model() override;
69 
70  std::string name() const override { return "BrownCameraDistortionModel"; }
71 
72  bool set_params(size_t width, size_t height,
73  const Eigen::VectorXf& params) override;
74 
76  return intrinsic_params_;
77  }
78 
79  inline Eigen::Matrix<float, 5, 1> get_distort_params() const {
80  return distort_params_;
81  }
82 
83  protected:
85  Eigen::Matrix<float, 5, 1> distort_params_;
86 };
87 
89  std::shared_ptr<BrownCameraDistortionModel>;
90 
92  std::shared_ptr<const BrownCameraDistortionModel>;
93 
94 } // namespace base
95 } // namespace perception
96 } // namespace apollo
Eigen::Matrix< float, 5, 1 > distort_params_
Definition: distortion_model.h:85
std::string name() const override
Definition: distortion_model.h:70
Eigen::Vector3f Vector3f
Definition: base_map_fwd.h:29
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Eigen::Matrix< float, 5, 1 > get_distort_params() const
Definition: distortion_model.h:79
std::shared_ptr< BrownCameraDistortionModel > BrownCameraDistortionModelPtr
Definition: distortion_model.h:89
Eigen::Matrix3f Matrix3f
Definition: base_map_fwd.h:27
size_t get_width() const
Definition: distortion_model.h:45
Eigen::Matrix3f intrinsic_params_
Definition: distortion_model.h:84
virtual bool set_params(size_t width, size_t height, const Eigen::VectorXf &params)=0
Eigen::Vector2f Vector2f
Definition: base_map_fwd.h:30
Eigen::Matrix3f get_intrinsic_params() const
Definition: distortion_model.h:75
virtual Eigen::Vector2f Project(const Eigen::Vector3f &point3d)=0
size_t get_height() const
Definition: distortion_model.h:44
virtual std::shared_ptr< BaseCameraModel > get_camera_model()=0
size_t height_
Definition: distortion_model.h:49
std::shared_ptr< const BrownCameraDistortionModel > BrownCameraDistortionModelConstPtr
Definition: distortion_model.h:92
size_t width_
Definition: distortion_model.h:48