Apollo  6.0
Open source self driving car software
camera.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 
17 #pragma once
18 
19 #include <memory>
20 #include <string>
21 
22 #include "Eigen/Core"
23 
24 namespace apollo {
25 namespace perception {
26 namespace base {
27 
29  public:
30  virtual ~BaseCameraModel() = default;
31 
32  virtual Eigen::Vector2f Project(const Eigen::Vector3f& point3d) = 0;
33  virtual Eigen::Vector3f UnProject(const Eigen::Vector2f& point2d) = 0;
34  virtual std::string name() const = 0;
35 
36  inline void set_width(size_t width) { image_width_ = width; }
37  inline void set_height(size_t height) { image_height_ = height; }
38 
39  inline size_t get_width() const { return image_width_; }
40  inline size_t get_height() const { return image_height_; }
41 
42  protected:
43  size_t image_width_ = 0;
44  size_t image_height_ = 0;
45 };
46 
48  public:
49  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
50 
51  public:
52  ~PinholeCameraModel() = default;
53 
54  Eigen::Vector2f Project(const Eigen::Vector3f& point3d) override;
55  Eigen::Vector3f UnProject(const Eigen::Vector2f& point2d) override;
56  std::string name() const override { return "PinholeCameraModel"; }
57 
58  inline void set_intrinsic_params(const Eigen::Matrix3f& params) {
59  intrinsic_params_ = params;
60  }
61 
63  return intrinsic_params_;
64  }
65 
66  protected:
67  /* fx 0 cx
68  0 fy cy
69  0 0 1
70  */
72 };
73 
74 // TODO(all) remove later
75 typedef std::shared_ptr<BaseCameraModel> BaseCameraModelPtr;
76 typedef std::shared_ptr<const BaseCameraModel> BaseCameraModelConstPtr;
77 typedef std::shared_ptr<PinholeCameraModel> PinholeCameraModelPtr;
78 typedef std::shared_ptr<const PinholeCameraModel> PinholeCameraModelConstPtr;
79 
80 } // namespace base
81 } // namespace perception
82 } // namespace apollo
std::shared_ptr< const BaseCameraModel > BaseCameraModelConstPtr
Definition: camera.h:76
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
std::shared_ptr< PinholeCameraModel > PinholeCameraModelPtr
Definition: camera.h:77
void set_width(size_t width)
Definition: camera.h:36
size_t get_height() const
Definition: camera.h:40
void set_intrinsic_params(const Eigen::Matrix3f &params)
Definition: camera.h:58
void set_height(size_t height)
Definition: camera.h:37
virtual std::string name() const =0
Eigen::Matrix3f Matrix3f
Definition: base_map_fwd.h:27
std::string name() const override
Definition: camera.h:56
size_t image_height_
Definition: camera.h:44
Eigen::Matrix3f get_intrinsic_params() const
Definition: camera.h:62
size_t image_width_
Definition: camera.h:43
virtual Eigen::Vector3f UnProject(const Eigen::Vector2f &point2d)=0
Eigen::Vector2f Vector2f
Definition: base_map_fwd.h:30
std::shared_ptr< BaseCameraModel > BaseCameraModelPtr
Definition: camera.h:75
virtual Eigen::Vector2f Project(const Eigen::Vector3f &point3d)=0
Eigen::Matrix3f intrinsic_params_
Definition: camera.h:71
std::shared_ptr< const PinholeCameraModel > PinholeCameraModelConstPtr
Definition: camera.h:78
size_t get_width() const
Definition: camera.h:39