10 #include "../../../src/algo/depth-to-rgb-calibration/k-to-dsm.h" 11 #include "../../filesystem.h" 15 return join(
join( scene_dir,
"binFiles" ),
"ac2" );
36 template<
typename T >
41 throw std::runtime_error(
"failed to read file:\n" + filename );
43 size_t cb = f.tellg();
45 if( cb !=
sizeof(
T ) )
47 <<
"file size (" << cb <<
") does not match data size (" <<
sizeof(
T ) <<
"): " << filename );
48 std::vector< T > vec( cb /
sizeof(
T ) );
49 f.read( (
char *)data, cb );
53 template<
typename T >
58 throw std::runtime_error(
"failed to read file:\n" + filename);
60 size_t cb = f.tellg();
63 throw std::runtime_error(
"file size is not a multiple of data size");
65 f.read((
char *)&obj, cb);
70 template<
typename T >
75 throw std::runtime_error(
"failed to read file:\n" + filename );
77 size_t cb = f.tellg();
79 if( cb %
sizeof(
T ) )
80 throw std::runtime_error(
"file size is not a multiple of data size" );
81 std::vector< T > vec( cb /
sizeof(
T ) );
82 f.read( (
char *)vec.data(), cb );
90 std::vector< std::vector<double> >
res;
94 throw std::runtime_error(
"failed to read file:\n" + filename);
96 size_t cb = f.tellg();
98 if (cb %
sizeof(
double))
99 throw std::runtime_error(
"file size is not a multiple of data size");
103 for (
size_t i = 0;
i < size_x;
i++)
105 res[
i].resize(size_y);
106 f.read((
char *)res[
i].
data(), size_y *
sizeof(
double));
131 throw std::runtime_error(
"invalid file: " + file );
133 size_t cb = f.tellg();
135 if( cb !=
sizeof(
T ) * width * height )
137 <<
"file size (" << cb <<
") does not match expected size (" <<
sizeof(
T ) * width * height <<
"): " << file );
138 std::vector< T >
data( width * height );
139 f.read( (
char *)data.data(), width * height *
sizeof(
T ) );
143 template <
typename T >
144 void dump_vec( std::vector< double >
const & cpp, std::vector< T >
const & matlab,
145 char const * basename,
154 throw std::runtime_error(
"failed to write file:\n" + filename );
156 std::vector< T > vec( cb /
sizeof(
T ) );
157 f.read( (
char*)vec.data(), cb );
184 std::ifstream(
join(
bin_dir( scene_dir ),
"yuy_prev_z_i.files" ) ) >> rgb_file
186 if( rgb_file.empty() )
187 throw std::runtime_error(
"failed to read file:\n" +
bin_dir( scene_dir ) +
"yuy_prev_z_i.files" );
188 if( ir_file.empty() )
189 throw std::runtime_error(
"not enough files in:\n" +
bin_dir( scene_dir ) +
"yuy_prev_z_i.files" );
194 throw std::runtime_error(
"failed to read file:\n" + metadata );
195 f.read( (
char *)&correction_in_pixels,
sizeof( correction_in_pixels ) );
196 f.read( (
char *)&n_edges,
sizeof( n_edges ) );
197 f.read( (
char *)&n_valid_ir_edges,
sizeof( n_valid_ir_edges ) );
198 f.read( (
char *)&n_valid_pixels,
sizeof( n_valid_pixels ) );
199 f.read((
char *)&n_relevant_pixels,
sizeof(n_relevant_pixels));
200 f.read( (
char *)&n_cycles,
sizeof( n_cycles ) );
203 is_scene_valid = b != 0;
205 is_output_valid = b != 0;
222 float z_units = 0.25;
238 double matrix_3x3[9];
239 double translation[3];
250 int( param.rgb_width ), int( param.rgb_height ),
257 int( param.depth_width ), int( param.depth_height ),
263 { param.matrix_3x3[0], param.matrix_3x3[1], param.matrix_3x3[2],
264 param.matrix_3x3[3], param.matrix_3x3[4], param.matrix_3x3[5],
265 param.matrix_3x3[6], param.matrix_3x3[7], param.matrix_3x3[8] },
266 { param.translation[0], param.translation[1], param.translation[2] }
282 #pragma pack(push, 1) 283 struct algo_calibration
286 float fovexNominal[4];
292 float undistAngHorz[4];
293 float pitchFixFactor;
299 algo_calibration algo_calib;
304 throw std::runtime_error(
"failed to read file:\n" + dsmparams);
306 f.read( (
char *)&algo_calibration_registers,
308 f.read( (
char *)&algo_calib,
sizeof( algo_calibration ) );
317 for (
auto i = 0;
i < 4;
i++)
326 for (
auto i = 0;
i < 5;
i++)
332 for (
auto i = 0;
i < 3;
i++)
GLboolean GLboolean GLboolean b
librealsense::algo::depth_to_rgb_calibration::algo_calibration_registers algo_calibration_registers
std::string bin_file(std::string const &prefix, size_t cycle, size_t iteration, size_t w, size_t h, std::string const &suffix)
std::string join(const std::string &base, const std::string &path)
librealsense::algo::depth_to_rgb_calibration::algo_calibration_info cal_info
Video DSM (Digital Sync Module) parameters for calibration (same layout as in FW ac_depth_params) Thi...
std::vector< T > read_image_file(std::string const &file, size_t width, size_t height)
uint8_t FRMWfovexExistenceFlag
GLdouble GLdouble GLdouble w
GLsizei const GLchar *const * string
GLfloat GLfloat GLfloat GLfloat h
float FRMWundistAngHorz[4]
librealsense::algo::depth_to_rgb_calibration::algo_calibration_registers cal_regs
std::vector< T > read_vector_from(std::string const &filename, size_t size_x=0, size_t size_y=0)
GLint GLenum GLint const GLfloat * coeffs
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
librealsense::algo::depth_to_rgb_calibration::rs2_intrinsics_double z
T read_from(std::string const &filename)
GLint GLsizei GLsizei height
unsigned __int64 uint64_t
float FRMWfovexNominal[4]
librealsense::algo::depth_to_rgb_calibration::rs2_extrinsics_double extrinsics
camera_params read_camera_params(std::string const &scene_dir, std::string const &filename)
rs2_dsm_params dsm_params
::realsense_legacy_msgs::metadata_< std::allocator< void > > metadata
librealsense::algo::depth_to_rgb_calibration::rs2_intrinsics_double rgb
const GLuint GLenum const void * binary
void dump_vec(std::vector< double > const &cpp, std::vector< T > const &matlab, char const *basename, size_t width, size_t height)
std::string bin_dir(std::string const &scene_dir)
dsm_params read_dsm_params(std::string const &scene_dir, std::string const &filename)
librealsense::algo::depth_to_rgb_calibration::algo_calibration_info regs
std::string to_string(T value)
void read_data_from(std::string const &filename, T *data)