supereight
pinhole_camera.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2020-2022 Smart Robotics Lab, Imperial College London, Technical University of Munich
3  * SPDX-FileCopyrightText: 2020-2022 Nils Funk
4  * SPDX-FileCopyrightText: 2020-2022 Sotiris Papatheodorou
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef SE_PINHOLE_CAMERA_HPP
9 #define SE_PINHOLE_CAMERA_HPP
10 
11 
12 
13 namespace se {
14 
18  float fx = std::numeric_limits<float>::quiet_NaN();
19 
22  float fy = std::numeric_limits<float>::quiet_NaN();
23 
26  float cx = std::numeric_limits<float>::quiet_NaN();
27 
30  float cy = std::numeric_limits<float>::quiet_NaN();
31 
35  void readYaml(const std::string& filename);
36 
37  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
38 };
39 
40 std::ostream& operator<<(std::ostream& os, const PinholeCameraConfig& c);
41 
42 
43 
44 class PinholeCamera : public SensorBase<PinholeCamera> {
45  public:
46  PinholeCamera(const PinholeCameraConfig& config);
47 
48  PinholeCamera(const PinholeCameraConfig& config, const float downsampling_factor);
49 
50  PinholeCamera(const PinholeCamera& pinhole_camera, const float downsampling_factor);
51 
52  int computeIntegrationScaleImpl(const Eigen::Vector3f& block_centre,
53  const float map_res,
54  const int last_scale,
55  const int min_scale,
56  const int max_block_scale) const;
57 
58  float nearDistImpl(const Eigen::Vector3f& ray_S) const;
59 
60  float farDistImpl(const Eigen::Vector3f& ray_S) const;
61 
62  float measurementFromPointImpl(const Eigen::Vector3f& point_S) const;
63 
64  bool pointInFrustumImpl(const Eigen::Vector3f& point_S) const;
65 
66  bool pointInFrustumInfImpl(const Eigen::Vector3f& point_S) const;
67 
68  bool sphereInFrustumImpl(const Eigen::Vector3f& centre_S, const float radius) const;
69 
70  bool sphereInFrustumInfImpl(const Eigen::Vector3f& centre_S, const float radius) const;
71 
72  static std::string typeImpl();
73 
74  srl::projection::PinholeCamera<srl::projection::NoDistortion> model;
75  float scaled_pixel;
76 
79 
81  float vertical_fov;
82 
83  void computeFrustumVertices();
84  void computeFrustumNormals();
85 
86  static constexpr int num_frustum_vertices_ = 8;
87  static constexpr int num_frustum_normals_ = 6;
88  Eigen::Matrix<float, 3, num_frustum_vertices_> frustum_vertices_;
89  Eigen::Matrix<float, 4, num_frustum_normals_> frustum_normals_;
90 
91  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
92 };
93 
94 
95 
96 } // namespace se
97 
98 #include "impl/pinhole_camera_impl.hpp"
99 
100 #endif // SE_PINHOLE_CAMERA_HPP
float fx
The sensor&#39;s horizontal focal length in pixels.
Definition: pinhole_camera.hpp:18
std::ostream & operator<<(std::ostream &os, const FieldDataConfig< se::Field::Occupancy > &c)
void readYaml(const std::string &filename)
Reads the struct members from the "sensor" node of a YAML file.
Definition: pinhole_camera.hpp:44
float fy
The sensor&#39;s vertical focal length in pixels.
Definition: pinhole_camera.hpp:22
Eigen::Matrix< float, 3, num_frustum_vertices_ > frustum_vertices_
Definition: pinhole_camera.hpp:88
Definition: pinhole_camera.hpp:15
srl::projection::PinholeCamera< srl::projection::NoDistortion > model
Definition: pinhole_camera.hpp:74
Eigen::Matrix< float, 4, num_frustum_normals_ > frustum_normals_
Definition: pinhole_camera.hpp:89
float cy
The sensor&#39;s optical centre vertical coordinate in pixels.
Definition: pinhole_camera.hpp:30
Definition: sensor.hpp:55
float scaled_pixel
Definition: pinhole_camera.hpp:75
float vertical_fov
The vertical field of view in radians.
Definition: pinhole_camera.hpp:81
float cx
The sensor&#39;s optical centre horizontal coordinate in pixels.
Definition: pinhole_camera.hpp:26
Definition: sensor.hpp:23
float horizontal_fov
The horizontal field of view in radians.
Definition: pinhole_camera.hpp:78
Helper wrapper to allocate and de-allocate octants in the octree.
Definition: colour_utils.hpp:17