calibration-types.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 
6 #include <cstdint> // all the basic types (uint8_t)
7 #include <vector> // all the basic types (uint8_t)
8 
9 
10 namespace librealsense {
11 namespace algo {
13 
14 
15  struct double3
16  {
17  double x, y, z;
18  double & operator [] ( int i ) { return (&x)[i]; }
19  bool operator == (const double3 d) { return x == d.x && y == d.y && z == d.z; }
20  bool operator != (const double3 d) { return !(*this == d); }
21  double3 operator-(const double3& other) {
22  return { x - other.x, y - other.y , z - other.z };
23  }
24 
25  double get_norm() const
26  {
27  return x*x + y * y + z * z;
28  }
29 
30  double3 operator*(const double& scalar) const {
31  return { x * scalar , y * scalar , z * scalar };
32  }
33 
34  double operator*(const double3& s) const {
35  return x * s.x + y * s.y + z * s.z;
36  }
37  };
38 
39  struct double2
40  {
41  double x, y;
42  double & operator [] ( int i ) { return (&x)[i]; };
43  bool operator == (const double2 & d) const { return x == d.x && y == d.y; }
44  bool operator != (const double2 & d) const { return !(*this == d); }
45  };
46 
47  struct double3x3
48  {
49  /* double3x3(double arr[9])
50  {
51  for (auto i = 0; i < 3; i++)
52  {
53  for (auto j = 0; j < 3; j++)
54  {
55  mat[i][j] = arr[i * 3 + j];
56  }
57  }
58  }*/
59  double mat[3][3];
61  {
62  double3x3 res = { {0} };
63 
64  for( auto i = 0; i < 3; i++ )
65  {
66  for( auto j = 0; j < 3; j++ )
67  {
68  res.mat[i][j] = mat[j][i];
69  }
70  }
71  return res;
72  }
73 
74  double3x3 operator*( const double3x3 & other )
75  {
76  double3x3 res = { {0} };
77 
78  for( auto i = 0; i < 3; i++ )
79  {
80  for( auto j = 0; j < 3; j++ )
81  {
82  double sum = 0;
83  for( auto l = 0; l < 3; l++ )
84  {
85  sum += mat[i][l] * other.mat[l][j];
86  }
87  res.mat[i][j] = sum;
88  }
89  }
90  return res;
91  }
92 
93  double3 operator*( const double3 & other )
94  {
95  double3 res = { 0 };
96 
97  res.x = mat[0][0] * other.x + mat[0][1] * other.y + mat[0][2] * other.z;
98  res.y = mat[1][0] * other.x + mat[1][1] * other.y + mat[1][2] * other.z;
99  res.z = mat[2][0] * other.x + mat[2][1] * other.y + mat[2][2] * other.z;
100  return res;
101  }
102 
103  std::vector< double > to_vector()
104  {
105  std::vector< double > res;
106  for( auto i = 0; i < 3; i++ )
107  {
108  for( auto j = 0; j < 3; j++ )
109  {
110  res.push_back( mat[i][j] );
111  }
112  }
113  return res;
114  }
115  };
116 
118  {
119  //deg_111, //to be aligned with matlab (maybe should be removed later)
120  deg_0, // 0, 1
121  deg_45, //1, 1
122  deg_90, //1, 0
123  deg_135, //1, -1
129  };
130 
132 
134  {
137  };
138  struct translation
139  {
140  double t1;
141  double t2;
142  double t3;
143  };
144 
145  struct matrix_3x3
146  {
147  double rot[9];
148 
150  {
151  return { rot[0], rot[3], rot[6],
152  rot[1], rot[4], rot[7],
153  rot[2], rot[5], rot[8] };
154  }
155  };
156 
158  {
159  double alpha;
160  double beta;
161  double gamma;
162 
163  bool operator==(const rotation_in_angles& other)
164  {
165  return alpha == other.alpha && beta == other.beta && gamma == other.gamma;
166  }
167  bool operator!=(const rotation_in_angles& other)
168  {
169  return !(*this == other);
170  }
171  bool operator<(const rotation_in_angles& other)
172  {
173  return (alpha < other.alpha) ||
174  (alpha == other.alpha && beta < other.beta) ||
175  (alpha == other.alpha && beta == other.beta && gamma < other.gamma);
176 
177  }
178  };
179 
182 
183  struct k_matrix
184  {
185  k_matrix() = default;
186  k_matrix(matrix_3x3 const & mat)
187  :k_mat(mat)
188  {}
189 
190  double get_fx() const { return k_mat.rot[0]; }
191  double get_fy() const { return k_mat.rot[4]; }
192  double get_ppx() const { return k_mat.rot[2]; }
193  double get_ppy() const { return k_mat.rot[5]; }
194 
196 
198  {
199  return k_mat;
200  }
201  };
202 
203 } // librealsense::algo::depth_to_rgb_calibration
204 } // librealsense::algo
205 } // librealsense
rotation_in_angles extract_angles_from_rotation(const double r[9])
GLdouble s
d
Definition: rmse.py:171
unsigned char uint8_t
Definition: stdint.h:78
GLdouble GLdouble r
GLint j
int i
GLuint res
Definition: glext.h:8856
matrix_3x3 extract_rotation_from_angles(const rotation_in_angles &rot_angles)
double3 operator*(const double &scalar) const


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:45:07