LOST  0.0.1
LOST: Open-source Star Tracker
camera.hpp
Go to the documentation of this file.
1 #ifndef CAMERA_H
2 #define CAMERA_H
3 
4 #include "attitude-utils.hpp"
5 
6 namespace lost {
7 
9 class Camera {
10 public:
11  Camera(const Camera &) = default;
12 
16  Camera(decimal focalLength,
17  decimal xCenter, decimal yCenter,
18  int xResolution, int yResolution)
19  : focalLength(focalLength),
20  xCenter(xCenter), yCenter(yCenter),
21  xResolution(xResolution), yResolution(yResolution) {};
22 
23  Camera(decimal focalLength, int xResolution, int yResolution)
24  : Camera(focalLength,
25  xResolution / DECIMAL(2.0), yResolution / DECIMAL(2.0),
26  xResolution, yResolution) {};
27 
28  Vec2 SpatialToCamera(const Vec3 &) const;
29  Vec3 CameraToSpatial(const Vec2 &) const;
30 
31  // converts from a 2d point in the camera sensor to right ascension and declination relative to
32  // the center of the camera.
33  // void CoordinateAngles(const Vec2 &vector, decimal *ra, decimal *de) const;
34 
35  bool InSensor(const Vec2 &vector) const;
36 
38  int XResolution() const { return xResolution; };
40  int YResolution() const { return yResolution; };
42  decimal FocalLength() const { return focalLength; };
44  decimal Fov() const;
45 
46  void SetFocalLength(decimal focalLength) { this->focalLength = focalLength; }
47 
48 private:
49  // TODO: distortion
50  decimal focalLength;
51  decimal xCenter; decimal yCenter;
52  int xResolution; int yResolution;
53 };
54 
55 decimal FovToFocalLength(decimal xFov, decimal xResolution);
56 
57 }
58 
59 #endif
A full description of a camera. Enough information to reconstruct the camera matrix and then some.
Definition: camera.hpp:9
Vec2 SpatialToCamera(const Vec3 &) const
Converts from a 3D point in space to a 2D point on the camera sensor.
Definition: camera.cpp:15
Camera(const Camera &)=default
void SetFocalLength(decimal focalLength)
Definition: camera.hpp:46
bool InSensor(const Vec2 &vector) const
Returns whether a given pixel is actually in the camera's field of view.
Definition: camera.cpp:51
Camera(decimal focalLength, decimal xCenter, decimal yCenter, int xResolution, int yResolution)
Definition: camera.hpp:16
int XResolution() const
Width of the sensor in pixels.
Definition: camera.hpp:38
int YResolution() const
Height of the sensor in pixels.
Definition: camera.hpp:40
decimal Fov() const
Horizontal field of view in radians.
Definition: camera.cpp:66
Vec3 CameraToSpatial(const Vec2 &) const
Gives a point in 3d space that could correspond to the given vector, using the same coordinate system...
Definition: camera.cpp:35
Camera(decimal focalLength, int xResolution, int yResolution)
Definition: camera.hpp:23
decimal FocalLength() const
Focal length in pixels.
Definition: camera.hpp:42
Three dimensional vector with decimaling point components.
double decimal
Definition: decimal.hpp:11
#define DECIMAL(x)
Definition: decimal.hpp:21
LOST starting point.
decimal FovToFocalLength(decimal xFov, decimal xResolution)
Definition: camera.cpp:58
A two dimensional vector with decimaling point components.