calibration.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 "calibration-types.h"
7 #include <types.h> // librealsense types (intr/extr)
8 
9 
10 namespace librealsense {
11 namespace algo {
12 namespace depth_to_rgb_calibration {
13 
14 
17  {
18  rs2_intrinsics_double() = default;
19 
20  rs2_intrinsics_double( const int width, const int height,
21  const k_matrix& k_mat, const rs2_distortion model, const double coeffs[5] )
22  :width( width ), height( height ),
23  ppx( k_mat.get_ppx() ), ppy( k_mat.get_ppy()),
24  fx( k_mat.get_fx()), fy( k_mat.get_fy()),
25  model( model ),
26  coeffs{ coeffs[0], coeffs[1], coeffs[2], coeffs[3], coeffs[4] }
27  {}
28 
30  :width( obj.width ), height( obj.height ),
31  ppx( obj.ppx ), ppy( obj.ppy ),
32  fx( obj.fx ), fy( obj.fy ),
33  model( obj.model ),
34  coeffs{ obj.coeffs[0], obj.coeffs[1], obj.coeffs[2], obj.coeffs[3], obj.coeffs[4] }
35  {}
36 
37  operator rs2_intrinsics() const
38  {
39  return
40  { width, height,
41  float( ppx ), float( ppy ),
42  float( fx ), float( fy ),
43  model,
44  {float( coeffs[0] ), float( coeffs[1] ), float( coeffs[2] ), float( coeffs[3] ), float( coeffs[4] )} };
45  }
46 
47  operator k_matrix() const
48  {
49  matrix_3x3 res =
50  { fx, 0, ppx,
51  0, fy, ppy,
52  0,0,1 };
53  return res;
54  }
55 
56  int width;
57  int height;
58  double ppx;
59  double ppy;
60  double fx;
61  double fy;
63  double coeffs[5];
64  };
65 
68  {
70  rs2_extrinsics_double( const matrix_3x3& rot, const translation& trans )
71  :rotation{ rot.rot[0], rot.rot[1],rot.rot[2],
72  rot.rot[3], rot.rot[4], rot.rot[5],
73  rot.rot[6], rot.rot[7], rot.rot[8] },
74  translation{ trans.t1, trans.t2 , trans.t3 }
75  {}
76 
78  :rotation{ other.rotation[0], other.rotation[1], other.rotation[2],
79  other.rotation[3], other.rotation[4], other.rotation[5],
80  other.rotation[6], other.rotation[7], other.rotation[8] },
81  translation{ other.translation[0], other.translation[1] , other.translation[2] }
82  {}
83 
84  operator rs2_extrinsics()
85  {
86  return { {float( rotation[0] ), float( rotation[1] ), float( rotation[2] ),
87  float( rotation[3] ), float( rotation[4] ), float( rotation[5] ),
88  float( rotation[6] ), float( rotation[7] ), float( rotation[8] )} ,
89  {float( translation[0] ), float( translation[1] ), float( translation[2] )} };
90  }
91 
92  double rotation[9];
93  double translation[3];
94  };
95 
96  struct krt
97  {
98  matrix_3x3 rot = { { 0 } };
99  translation trans = { 0 };
100  k_matrix k_mat = matrix_3x3{ 0 };
101  };
102 
103  struct p_matrix
104  {
105  double vals[12];
106 
107  bool operator<( const p_matrix & other ) const
108  {
109  for (auto i = 0; i < 12; i++)
110  {
111  if (vals[i] < other.vals[i])
112  return false;
113  if (vals[i] > other.vals[i])
114  return true;
115  }
116  return true;
117  }
118  p_matrix operator*(double step_size) const;
119  p_matrix operator/(double factor) const;
120  p_matrix operator+(const p_matrix& c) const;
121  p_matrix operator-(const p_matrix& c) const;
122  p_matrix operator/(const p_matrix& c) const;
123  p_matrix operator*(const p_matrix& c) const;
124 
125  double get_norma() const;
126  double sum() const;
127  p_matrix normalize( double norm ) const;
128  double matrix_norm() const;
129 
130  krt decompose() const;
131  };
132 
133  struct calib
134  {
135  matrix_3x3 rot = { { 0 } };
136  translation trans = { 0 };
137  k_matrix k_mat = matrix_3x3{ 0};
138  int width = 0;
139  int height = 0;
141  double coeffs[5];
142 
143  calib() = default;
144  calib( calib const & ) = default;
145  explicit calib( rs2_intrinsics_double const & rgb_intrinsics, rs2_extrinsics_double const & depth_to_rgb_extrinsics);
146  explicit calib( rs2_intrinsics const & rgb_intrinsics, rs2_extrinsics const & depth_to_rgb_extrinsics);
147 
148  rs2_intrinsics_double get_intrinsics() const;
150 
151  p_matrix const calc_p_mat() const;
152 
153  void copy_coefs( calib & obj ) const;
154  calib operator*( double step_size ) const;
155  calib operator/( double factor ) const;
156  calib operator+( const calib& c ) const;
157  calib operator-( const calib& c ) const;
158  calib operator/( const calib& c ) const;
159  };
160 
161  calib decompose( p_matrix const & mat, calib const & );
162 
163 }
164 }
165 }
166 
bool operator<(const p_matrix &other) const
Definition: calibration.h:107
float3 operator-(const float3 &a, const float3 &b)
Definition: src/types.h:580
rs2_distortion
Distortion model: defines how pixel coordinates should be mapped to sensor coordinates.
Definition: rs_types.h:45
float3 operator*(const float3 &a, float b)
Definition: src/types.h:581
calib decompose(p_matrix const &mat, calib const &)
float coeffs[5]
Definition: rs_types.h:67
GLhandleARB obj
Definition: glext.h:4157
float rotation[9]
Definition: rs_sensor.h:98
rs2_intrinsics_double(const int width, const int height, const k_matrix &k_mat, const rs2_distortion model, const double coeffs[5])
Definition: calibration.h:20
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
Definition: calibration.h:67
const GLubyte * c
Definition: glext.h:12690
GLint GLsizei GLsizei height
rs2_intrinsics normalize(const rs2_intrinsics &intr)
Definition: l500-color.cpp:272
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
Definition: rs_sensor.h:96
struct rs2_intrinsics rs2_intrinsics
Video stream intrinsics.
Video stream intrinsics.
Definition: rs_types.h:58
struct rs2_extrinsics rs2_extrinsics
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
int i
GLuint res
Definition: glext.h:8856
float3 operator+(const float3 &a, const float3 &b)
Definition: src/types.h:579
def get_extrinsics(src, dst)
Definition: t265_stereo.py:57
rs2_intrinsics operator/(const rs2_intrinsics &i, int f)
rs2_extrinsics_double(const matrix_3x3 &rot, const translation &trans)
Definition: calibration.h:70
GLint GLsizei width


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