My Project
Loading...
Searching...
No Matches
camera.hpp
1#ifndef CAMERA_H
2#define CAMERA_H
3
4#include "spatial/attitude-utils.hpp"
5
6#include "style/style.hpp"
7
8namespace found {
9
17class Camera {
18 public:
22 Camera(const Camera &) = default;
23
32 Camera(decimal focalLength,
33 decimal xCenter, decimal yCenter,
34 int xResolution, int yResolution)
35 : focalLength(focalLength),
36 xCenter(xCenter), yCenter(yCenter),
37 xResolution(xResolution), yResolution(yResolution) {}
38
49 Camera(decimal focalLength, int xResolution, int yResolution)
50 : Camera(focalLength,
51 xResolution / (decimal) 2.0, yResolution / (decimal) 2.0,
52 xResolution, yResolution) {}
53
54 // Projection of vectors into image and space
55
56 Vec2 SpatialToCamera(const Vec3 &) const;
57 Vec3 CameraToSpatial(const Vec2 &) const;
58
59 bool InSensor(const Vec2 &vector) const;
60
61 // Accessor Methods to Camera Parameters
62
68 int XResolution() const { return xResolution; }
69
75 int YResolution() const { return yResolution; }
76
82 decimal FocalLength() const { return focalLength; }
83
84 decimal Fov() const;
85
86 // Mutator Method for Cameras
87
93 void SetFocalLength(decimal focalLength) { this->focalLength = focalLength; }
94
95 private:
96 // TODO: distortion
97 decimal focalLength;
98 decimal xCenter; decimal yCenter;
99 int xResolution; int yResolution;
100};
101
102// Conversions from FOV to Focal Length
103
104decimal FovToFocalLength(decimal xFov, decimal xResolution);
105decimal FocalLengthToFov(decimal focalLength, decimal xResolution, decimal pixelSize);
106
107} // namespace found
108
109#endif
Definition camera.hpp:17
bool InSensor(const Vec2 &vector) const
Definition camera.cpp:68
int XResolution() const
Definition camera.hpp:68
Camera(decimal focalLength, int xResolution, int yResolution)
Definition camera.hpp:49
Camera(decimal focalLength, decimal xCenter, decimal yCenter, int xResolution, int yResolution)
Definition camera.hpp:32
Camera(const Camera &)=default
decimal Fov() const
Definition camera.cpp:82
decimal FocalLength() const
Definition camera.hpp:82
Vec3 CameraToSpatial(const Vec2 &) const
Definition camera.cpp:46
int YResolution() const
Definition camera.hpp:75
Vec2 SpatialToCamera(const Vec3 &) const
Definition camera.cpp:21
void SetFocalLength(decimal focalLength)
Definition camera.hpp:93
Definition attitude-utils.hpp:47
Definition converters.hpp:10
decimal FovToFocalLength(decimal xFov, decimal xResolution)
Definition camera.cpp:96
decimal FocalLengthToFov(decimal focalLength, decimal xResolution, decimal pixelSize)
Definition camera.cpp:111
Definition attitude-utils.hpp:18