mf
Media Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
camera.h
Go to the documentation of this file.
1 #ifndef MF_CAMERA_H_
2 #define MF_CAMERA_H_
3 
4 #include "../eigen.h"
5 #include <array>
6 #include <utility>
7 #include "../space_object.h"
8 #include "../geometry/spherical_coordinates.h"
9 #include "../eigen.h"
10 
11 namespace mf {
12 
14 
16 class camera : public space_object {
17 protected:
18  camera() = default;
19  explicit camera(const pose&);
20 
21 public:
22  camera(const camera&) = default;
23  camera& operator=(const camera&) = default;
24 
26 
27  virtual ~camera() = default;
28 
30 
32 
34 
36  return ray_direction(Eigen_vec3(0, 0, -1));
37  }
38 
41  return ray_direction(point(sp));
42  }
43 
45  Eigen_vec3 ray_direction(const Eigen_vec3& p) const;
46 
48  float distance_sq(const Eigen_vec3& p) const;
49 
51  float distance(const Eigen_vec3& p) const;
52 
55 
57  Eigen_vec3 point(const spherical_coordinates& sp) const;
58 
60 
61  virtual image_coordinates_type project(const Eigen_vec3& p) const = 0;
62 
64 
66  return this->project(point(sp));
67  }
68 
70 
71  virtual Eigen_vec3 ray_direction(const image_coordinates_type& c) const = 0;
72 };
73 
74 }
75 
76 #endif
Eigen_vec2 image_coordinates_type
2D image coordinates, range and scale defined by subclass.
Definition: camera.h:25
Eigen_vec3 point(const spherical_coordinates &sp) const
Convert 3D point spherical coordinates sp to cartesian.
Definition: camera.cc:29
Eigen_affine3 view_transformation() const
Extrinsic parameters of camera.
Definition: camera.cc:9
Eigen_mat< 2, 1 > Eigen_vec2
Definition: eigen.h:24
Eigen_vec3 center_ray_direction() const
Direction vector of ray -Z pointing straight out camera.
Definition: camera.h:35
spherical_coordinates to_spherical(const Eigen_vec3 &p) const
Convert 3D point cartesian coordinates p to spherical.
Definition: camera.cc:25
Camera which defines mapping from 3D spatial coordinates to 2D image coordinates. ...
Definition: camera.h:16
Eigen::Transform< Eigen_scalar, 3, Eigen::Affine > Eigen_affine3
Definition: eigen.h:37
float distance(const Eigen_vec3 &p) const
Distance of 3D point p to camera center.
Definition: camera.cc:21
camera & operator=(const camera &)=default
virtual ~camera()=default
camera()=default
Position and orientation in space.
Definition: pose.h:15
float distance_sq(const Eigen_vec3 &p) const
Squared distance of 3D point p to camera center.
Definition: camera.cc:17
virtual image_coordinates_type project(const Eigen_vec3 &p) const =0
Project point p to image coordinates.
Spherical coordinates.
Definition: spherical_coordinates.h:16
Eigen_vec3 ray_direction(const spherical_coordinates &sp) const
Direction vector of ray pointing to point with spherical coordinates sp.
Definition: camera.h:40
Object that has a pose in 3D space relative to a coordinate system, base class.
Definition: space_object.h:19
virtual image_coordinates_type project(const spherical_coordinates &sp) const
Project point with spherical coordinates sp to image coordinates.
Definition: camera.h:65
Eigen_mat< 3, 1 > Eigen_vec3
Definition: eigen.h:25