-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.hpp
More file actions
60 lines (44 loc) · 1.4 KB
/
camera.hpp
File metadata and controls
60 lines (44 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#include "common_include.hpp"
namespace ECT_SLAM
{
// Pinhole stereo camera model
class Camera
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
typedef std::shared_ptr<Camera> Ptr;
double fx_ = 0, fy_ = 0, cx_ = 0, cy_ = 0; // Camera intrinsics
double k1_ = 0, k2_ = 0, r1_ = 0, r2_ = 0;
Camera();
Camera(double fx, double fy, double cx, double cy)
: fx_(fx), fy_(fy), cx_(cx), cy_(cy)
{
}
Mat33f K() const
{
Mat33f k;
k << fx_, 0, cx_, 0, fy_, cy_, 0, 0, 1;
return k;
}
// return intrinsic matrix
Mat33 K_d() const
{
Mat33 k;
k << fx_, 0, cx_, 0, fy_, cy_, 0, 0, 1;
return k;
}
// return intrinsic matrix
cv::Mat K_cv() const
{
return (cv::Mat1d(3, 3) << fx_, 0, cx_, 0, fy_, cy_, 0, 0, 1);
}
// coordinate transform: world, camera, pixel
Vec3 world2camera(const Vec3 &p_w, const SE3 &T_c_w);
Vec3 camera2world(const Vec3 &p_c, const SE3 &T_c_w);
Vec2 camera2pixel(const Vec3 &p_c);
Vec3 pixel2camera(const Vec2 &p_p, double depth = 1);
Vec3 pixel2world(const Vec2 &p_p, const SE3 &T_c_w, double depth = 1);
Vec2 world2pixel(const Vec3 &p_w, const SE3 &T_c_w);
};
} // namespace ECT_SLAM