OpenCV 4.5.3(日本語機械翻訳)
intrinsics.hpp
1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html
4
5 #ifndef __OPENCV_RGBD_INTRINSICS_HPP__
6 #define __OPENCV_RGBD_INTRINSICS_HPP__
7
8 #include "opencv2/core/matx.hpp"
9
10 namespace cv
11{
12 namespace kinfu
13{
14
15 struct Intr
16{
20 {
21 Reprojector() {}
22 inline Reprojector(Intr intr)
23 {
24 fxinv = 1.f/intr.fx, fyinv = 1.f/intr.fy;
25 cx = intr.cx, cy = intr.cy;
26 }
27 template<typename T>
28 inline cv::Point3_<T> operator()(cv::Point3_<T> p) const
29 {
30 T x = p.z * (p.x - cx) * fxinv;
31 T y = p.z * (p.y - cy) * fyinv;
32 return cv::Point3_<T>(x, y, p.z);
33 }
34
35 float fxinv, fyinv, cx, cy;
36 };
37
39 struct Projector
40 {
41 inline Projector(Intr intr) : fx(intr.fx), fy(intr.fy), cx(intr.cx), cy(intr.cy) { }
42 template<typename T>
43 inline cv::Point_<T> operator()(cv::Point3_<T> p) const
44 {
45 T invz = T(1)/p.z;
46 T x = fx*(p.x*invz) + cx;
47 T y = fy*(p.y*invz) + cy;
48 return cv::Point_<T>(x, y);
49 }
50 template<typename T>
51 inline cv::Point_<T> operator()(cv::Point3_<T> p, cv::Point3_<T>& pixVec) const
52 {
53 T invz = T(1)/p.z;
54 pixVec = cv::Point3_<T>(p.x*invz, p.y*invz, 1);
55 T x = fx*pixVec.x + cx;
56 T y = fy*pixVec.y + cy;
57 return cv::Point_<T>(x, y);
58 }
59 float fx, fy, cx, cy;
60 };
61 Intr() : fx(), fy(), cx(), cy() { }
62 Intr(float _fx, float _fy, float _cx, float _cy) : fx(_fx), fy(_fy), cx(_cx), cy(_cy) { }
63 Intr(cv::Matx33f m) : fx(m(0, 0)), fy(m(1, 1)), cx(m(0, 2)), cy(m(1, 2)) { }
64 // scale intrinsics to pyramid level
65 inline Intr scale(int pyr) const
66 {
67 float factor = (1.f /(1 << pyr));
68 return Intr(fx*factor, fy*factor, cx*factor, cy*factor);
69 }
70 inline Reprojector makeReprojector() const { return Reprojector(*this); }
71 inline Projector makeProjector() const { return Projector(*this); }
72
73 inline cv::Matx33f getMat() const { return Matx33f(fx, 0, cx, 0, fy, cy, 0, 0, 1); }
74
75 float fx, fy, cx, cy;
76};
77
78} // namespace rgbd
79} // namespace cv
80
81 #endif
Template class for small matrices whose type and size are known at compilation time
Definition: matx.hpp:100
Template class for 3D points specified by its coordinates x, y and z.
Definition: core/types.hpp:240
_Tp z
z coordinate of the 3D point
Definition: core/types.hpp:267
_Tp x
x coordinate of the 3D point
Definition: core/types.hpp:265
_Tp y
y coordinate of the 3D point
Definition: core/types.hpp:266
Template class for 2D points specified by its coordinates x and y.
Definition: core/types.hpp:158
cv
"black box" representation of the file storage associated with a file on disk.
Definition: aruco.hpp:75
Definition: intrinsics.hpp:40
Camera intrinsics
Definition: intrinsics.hpp:20
Definition: intrinsics.hpp:16