k-to-dsm.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.h"
7 #include "frame-data.h"
9 
10 #include <types.h> // librealsense types (intr/extr)
11 
12 namespace librealsense {
13 namespace algo {
14 namespace depth_to_rgb_calibration {
15 
16  static const int SIZE_OF_GRID_X = 25;
17  static const int SIZE_OF_GRID_Y = 6;
18 
20  {
23  };
24 
25 
27  {
28  double los_scaling_x;
29  double los_scaling_y;
30  double los_shift_x;
31  double los_shift_y;
32  };
33 
35  {
37  double h_scale;
38  double v_scale;
39  double h_offset;
40  double v_offset;
41  double rtd_offset;
43  rs2_dsm_params_double() = default;
45  : model( rs2_dsm_correction_model( obj.model ) )
46  , h_scale( obj.h_scale )
47  , v_scale( obj.v_scale )
48  , h_offset( obj.h_offset )
49  , v_offset( obj.v_offset )
50  , rtd_offset( obj.rtd_offset )
51  {
52  //todo: flags
53  }
54 
55  void copy_to( rs2_dsm_params & o )
56  {
57  o.h_scale = float( h_scale );
58  o.v_scale = float( v_scale );
59  o.h_offset = float( h_offset );
60  o.v_offset = float( v_offset );
61  o.rtd_offset = float( rtd_offset );
62  o.model = model;
63  }
64  };
65 
66  std::ostream & operator<<( std::ostream &, rs2_dsm_params_double const & );
67 
68 #pragma pack(push, 1)
69  // This table is read from FW and is used in the optimizer
70  // Best way to see this table and its formatting is in the Algo source code, under:
71  // eepromStructure/eepromStructure.mat
73  {
74  static const int table_id = 0x313;
75 
76  uint32_t DIGGundistFx; // x frequency of undist lut (1/distance between to neighbors in lut)
77  uint32_t DIGGundistFy; // y frequency of undist lut (1/distance between to neighbors in lut)
78  int32_t DIGGundistX0; // x input added offset- luts start from 0-0 but we can have negative x/y input
79  int32_t DIGGundistY0; // y input added offset- luts start from 0-0 but we can have negative x/y input
80  uint8_t DESThbaseline; // 0:/5;1:/95
81  float DESTbaseline; // [-35.0:35.0]:/50;[-160.0:160.0]:/45;[100.0:1000.0]:/5
82  float DESTtxFRQpd[3];
83  float FRMWxfov[5]; // output projection x fov [7.0:100.0]:/50;72.0:/50
84  float FRMWyfov[5]; // output projection y fov [7.0:90.0]:/50;56.0:/50
85  float FRMWprojectionYshear[5]; // output projection y shearing [-0.03:0.03]
86  float FRMWlaserangleH; // laser-mems angle [-3.0:3.0]
88  int16_t FRMWcalMarginL; // image margin [-256:1280]
92  uint8_t FRMWxR2L; // case the input angle arrives from high to low
93  uint8_t FRMWyflip; // flip the sign of the fast scan
94  float EXTLdsmXscale; // DSM conversion parameter [0.0:100000.0]
98  uint32_t EXTLconLocDelaySlow; // RegsAnsyncAsLateLatencyFixEn
99  uint32_t EXTLconLocDelayFastC; // RegsProjConLocDelay
100  uint32_t EXTLconLocDelayFastF; // RegsProjConLocDelayHfclkRes
101  uint16_t FRMWcalImgHsize; // horizontal image size in pixels
102  uint16_t FRMWcalImgVsize; // vertical image size in pixels
103  float FRMWpolyVars[3]; // horizontal angle stage 1 undist x^1 coefficient
104  float FRMWpitchFixFactor; // vertical angle stage 1 undist x^1 coefficient
105  uint32_t FRMWzoRawCol[5]; // Cal resolution zero order raw -x location
106  uint32_t FRMWzoRawRow[5]; // Cal resolution zero order raw -y location
107  float FRMWdfzCalTmp; // DFZ Calibration temperature [-1.0:90.0]
108  float FRMWdfzVbias[3]; // DFZ Calibration vBias1 [0.0:90.0]
109  float FRMWdfzIbias[3]; // DFZ Calibration iBias1 [0.0:90.0]
110  float FRMWdfzApdCalTmp; // DFZ Apd Calibration temperature [-1.0:90.0]
111  float FRMWatlMinVbias1; // Algo Thermal Loop Calibration min vBias1 [0.0:90.0]
112  float FRMWatlMaxVbias1; // Algo Thermal Loop Calibration max vBias1 [0.0:90.0]
113  float FRMWatlMinVbias2; // Algo Thermal Loop Calibration min vBias2 [0.0:90.0]
114  float FRMWatlMaxVbias2; // Algo Thermal Loop Calibration max vBias2 [0.0:90.0]
115  float FRMWatlMinVbias3; // Algo Thermal Loop Calibration min vBias3 [0.0:90.0]
116  float FRMWatlMaxVbias3; // Algo Thermal Loop Calibration max vBias3 [0.0:90.0]
117  float FRMWundistAngHorz[4]; // horz angle stage 2 undist: x^# coefficient
118  float FRMWundistAngVert[4]; // vert angle stage 2 undist: y^# coefficient
119  uint8_t FRMWfovexExistenceFlag; // fovex existence flag (0 = no FOVex)
120  float FRMWfovexNominal[4]; // fovex nominal opening model: r^# coefficient
121  uint8_t FRMWfovexLensDistFlag; // fovex lens distortion flag (1 = apply lens distortion model)
122  float FRMWfovexRadialK[3]; // fovex radial distortion: r^# coefficient
123  float FRMWfovexTangentP[2]; // fovex tangential distortion: r^2+2x^2 coefficient
124  float FRMWfovexCenter[2]; // fovex distortion center (horz & vert)
127  uint32_t FRMWeepromVersion; // EEPROM structure version
128  float FRMWconLocDelaySlowSlope; // slope of Z-IR delay correction vs. LDD temperature [nsec/deg]
129  float FRMWconLocDelayFastSlope; // slope of Z delay correction vs. LDD temperature [nsec/deg]
130  int16_t FRMWatlMinAngXL; // min DSM X angle on the lower side
131  int16_t FRMWatlMinAngXR; // min DSM X angle on the higher side
132  int16_t FRMWatlMaxAngXL; // max DSM X angle on the lower side
133  int16_t FRMWatlMaxAngXR; // max DSM X angle on the higher side
134  int16_t FRMWatlMinAngYU; // min DSM Y angle on the lower side
135  int16_t FRMWatlMinAngYB; // min DSM Y angle on the higher side
136  int16_t FRMWatlMaxAngYU; // max DSM Y angle on the lower side
137  int16_t FRMWatlMaxAngYB; // max DSM Y angle on the higher side
138  float FRMWatlSlopeMA; // Thermal rtd fix slope - deltaRtd = ma*slope + offset
139  float FRMWatlMaCalTmp; // Final ATC MA Calibration temperature
140  uint8_t FRMWvddVoltValues[3]; // sampled vdd voltage as measured during ACC calibration (2 uint12 values, or 24 bits total)
141  int16_t FRMWvdd2RtdDiff; // Range difference between 2nd vdd voltage and the 1st vdd voltage
144  float FRMWdfzCalibrationLddTemp; // ldd temperature during DFZ calibration at the ACC
145  float FRMWdfzCalibrationVddVal; // vdd value as measured during DFZ calibration at the ACC
146  float FRMWhumidApdTempDiff; // difference between SHTW2 and TSense readings at first TSense temperature above 20deg
147  float FRMWlosAtMirrorRestHorz; // horizontal LOS report at mirror rest during DSM calibration
148  float FRMWlosAtMirrorRestVert; // vertical LOS report at mirror rest during DSM calibration
149  uint8_t reserved[90];
150  };
151 
153  {
158  };
159 #pragma pack(pop)
160 
162  {
165  std::vector<double3> vertices_orig;
166  std::vector<uint8_t> relevant_pixels_image_rot;
167  std::vector<double2> los_orig;
168 
169  };
170  struct data_collect;
172 
173  class k_to_DSM
174  {
175  public:
176  k_to_DSM(const rs2_dsm_params_double& orig_dsm_params,
177  algo_calibration_info const & cal_info,
178  algo_calibration_registers const & cal_regs,
179  const double& max_scaling_step);
180 
181  algo_calibration_registers apply_ac_res_on_dsm_model(const rs2_dsm_params_double& ac_data,
182  const algo_calibration_registers& regs,
183  const ac_to_dsm_dir& type);
184 
185  los_shift_scaling convert_ac_data_to_los_error(const algo_calibration_registers& algo_calibration_registers,
186  const rs2_dsm_params_double& ac_data);
187 
188  pre_process_data pre_processing(const algo_calibration_info& regs,
189  const rs2_dsm_params_double& ac_data,
190  const algo_calibration_registers& algo_calibration_registers,
191  const rs2_intrinsics_double& k_raw,
192  const std::vector<uint8_t>& relevant_pixels_image,
193  data_collect* data = nullptr);
194 
195  //return rs2_dsm_params and new vertices
196  rs2_dsm_params_double convert_new_k_to_DSM(
197  const rs2_intrinsics_double& old_k,
198  const rs2_intrinsics_double& new_k,
199  const z_frame_data& z,
200  std::vector<double3>& new_vertices,
201  rs2_dsm_params_double const & previous_dsm_params,
202  algo_calibration_registers& new_dsm_regs,
203  data_collect* data = nullptr);
204 
205  const pre_process_data& get_pre_process_data() const;
206 
207  algo_calibration_info const & get_calibration_info() const { return _regs; }
208  algo_calibration_registers const & get_calibration_registers() const { return _dsm_regs; }
209 
210  private:
211  double2 convert_k_to_los_error(
213  algo_calibration_registers const &dsm_regs,
214  rs2_intrinsics_double const & k_raw,
215  data_collect* data = nullptr);
216 
217  rs2_dsm_params_double convert_los_error_to_ac_data(
218  const rs2_dsm_params_double& ac_data,
219  const algo_calibration_registers& dsm_regs,
220  double2 los_shift, double2 los_scaling);
221 
222  double2 run_scaling_optimization_step(
224  algo_calibration_registers const &dsm_regs,
225  double scaling_grid_x[SIZE_OF_GRID_X],
226  double scaling_grid_y[SIZE_OF_GRID_X],
227  double2 focal_scaling,
228  data_collect* data = nullptr);
229 
230  std::vector<double3x3> optimize_k_under_los_error(
232  algo_calibration_registers const &dsm_regs,
233  double scaling_grid_x[25],
234  double scaling_grid_y[25] );
235 
236  std::vector<double3> convert_los_to_norm_vertices(
238  algo_calibration_registers const &dsm_regs,
239  std::vector<double2> los,
240  data_collect* data = nullptr);
241 
242  std::vector<double3> calc_relevant_vertices(const std::vector<uint8_t>& relevant_pixels_image,
243  const rs2_intrinsics_double& k);
244 
245  std::vector<double2> convert_norm_vertices_to_los(const algo_calibration_info& regs,
246  const algo_calibration_registers& algo_calibration_registers,
247  std::vector<double3> const & vertices,
249 
250  double3 laser_incident_direction(double2 angle_rad);
251  std::vector< double3 > transform_to_direction( std::vector< double3 > const & );
252 
254 
255  //input camera params
258 
259  //algorithem params
261  };
262 
263 
264 
265 }
266 }
267 }
268 
269 
algo::depth_to_rgb_calibration::algo_calibration_info _regs
Definition: k-to-dsm.h:256
float rtd_offset
Definition: rs_types.h:84
float v_offset
Definition: rs_types.h:83
Video DSM (Digital Sync Module) parameters for calibration (same layout as in FW ac_depth_params) Thi...
Definition: rs_types.h:74
algo::depth_to_rgb_calibration::algo_calibration_registers _dsm_regs
Definition: k-to-dsm.h:257
float v_scale
Definition: rs_types.h:81
float h_scale
Definition: rs_types.h:80
unsigned short uint16_t
Definition: stdint.h:79
unsigned char model
Definition: rs_types.h:78
GLdouble GLdouble z
unsigned char uint8_t
Definition: stdint.h:78
GLhandleARB obj
Definition: glext.h:4157
Exposes RealSense structs.
unsigned int uint32_t
Definition: stdint.h:80
signed short int16_t
Definition: stdint.h:76
algo_calibration_registers const & get_calibration_registers() const
Definition: k-to-dsm.h:208
algo_calibration_info const & get_calibration_info() const
Definition: k-to-dsm.h:207
float h_offset
Definition: rs_types.h:82
static const struct @18 vertices[3]
GLenum type
std::ostream & operator<<(std::ostream &, rs2_dsm_params_double const &)
Definition: k-to-dsm.cpp:14
signed int int32_t
Definition: stdint.h:77
rs2_dsm_correction_model
Definition: rs_types.h:94
Definition: parser.hpp:150


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