mf
Media Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
projection_camera.h
Go to the documentation of this file.
1 #ifndef MF_PROJECTION_CAMERA_H_
2 #define MF_PROJECTION_CAMERA_H_
3 
4 #include "depth_camera.h"
5 #include "../geometry/projection_view_frustum.h"
6 #include "../ndarray/ndcoord.h"
7 #include <utility>
8 
9 namespace mf {
10 
12 
14 public:
18  };
19 
20 private:
21  using intrinsic_matrix_result = std::pair<projection_view_frustum, Eigen_projective3>;
22 
23  projection_view_frustum projection_frustum_;
24  Eigen_projective3 view_to_image_;
25  Eigen_projective3 world_to_image_;
26  Eigen_projective3 image_to_world_;
27 
28  static intrinsic_matrix_result read_intrinsic_matrix_
29  (const Eigen_mat3& intrinsic_matrix, const depth_projection_parameters&, const ndsize<2>&);
30 
31  projection_camera(const pose&, const intrinsic_matrix_result&);
32 
33 protected:
34  void do_update_pose() override;
35 
36 public:
38  projection_camera(const pose&, const Eigen_mat3& intrinsic, const depth_projection_parameters&, const ndsize<2>&);
39 
40  projection_camera(const projection_camera&) = default;
42 
43  const projection_view_frustum& relative_frustum() const { return projection_frustum_; }
44  const depth_projection_parameters& depth_parameters() const { return projection_frustum_.depth_parameters(); }
45 
46  image_coordinates_type project(const Eigen_vec3& p) const override {
47  return (world_to_image_ * p.homogeneous()).eval().hnormalized().head(2);
48  }
49 
50  real depth(const Eigen_vec3& p) const override {
51  return (world_to_image_ * p.homogeneous()).eval().hnormalized()[2];
52  }
53 
54  Eigen_vec3 ray_direction(const image_coordinates_type& c) const override {
55  real depth = 1.0;
56  Eigen_vec3 p(c[0], c[1], depth);
57  return (image_to_world_ * p.homogeneous()).eval().hnormalized().normalized();
58  }
59 
60  Eigen_vec3 point(const image_coordinates_type& c, real depth) const override {
61  Eigen_vec3 p(c[0], c[1], depth);
62  return (image_to_world_ * p.homogeneous()).eval().hnormalized();
63  }
64 
66 };
67 
68 
69 }
70 
71 #endif
Eigen_vec2 offset
After scaling, maps coordinates to [-scale+offset, +scale+offset].
Definition: projection_camera.h:17
Eigen_vec2 image_coordinates_type
2D image coordinates, range and scale defined by subclass.
Definition: camera.h:25
float real
Real number type.
Definition: common.h:48
const projection_view_frustum & relative_frustum() const
Definition: projection_camera.h:43
Parameters of Z to depth projection.
Definition: depth_projection_parameters.h:12
real depth(const Eigen_vec3 &p) const override
Definition: projection_camera.h:50
Eigen_mat< 3, 3 > Eigen_mat3
Definition: eigen.h:29
Eigen_mat< 2, 1 > Eigen_vec2
Definition: eigen.h:24
projection_camera & operator=(const projection_camera &)=default
Camera which maps 3D coordinates of point to depth value in addition to the 2D image coordinates...
Definition: depth_camera.h:9
Position and orientation in space.
Definition: pose.h:15
Eigen_vec3 point(const image_coordinates_type &c, real depth) const override
Definition: projection_camera.h:60
Vector of n-dimensional coordinates.
Definition: ndcoord.h:18
const depth_projection_parameters & depth_parameters() const
Definition: projection_camera.h:44
Eigen_vec3 ray_direction(const image_coordinates_type &c) const override
Direction vector of ray pointing to point corresponding to image coordinates c.
Definition: projection_camera.h:54
Eigen::Transform< Eigen_scalar, 3, Eigen::Projective > Eigen_projective3
Definition: eigen.h:40
const depth_projection_parameters & depth_parameters() const
Definition: view_frustum.h:44
void do_update_pose() override
Definition: projection_camera.cc:47
friend Eigen_projective3 homography_transformation(const projection_camera &from, const projection_camera &to)
Definition: projection_camera.cc:86
View frustum of a perspective camera, without pose.
Definition: projection_view_frustum.h:16
Pin-hole camera with projection to a planar image space.
Definition: projection_camera.h:13
Eigen_vec2 scale
Projected image coordinates in frustum are scaled from [-1, +1] to [-scale, +scale].
Definition: projection_camera.h:16
Eigen_mat< 3, 1 > Eigen_vec3
Definition: eigen.h:25
Definition: projection_camera.h:15
image_coordinates_type project(const Eigen_vec3 &p) const override
Project point p to image coordinates.
Definition: projection_camera.h:46