10 #define NO_CATCH_CONFIG_MAIN 13 #define DISABLE_LOG_TO_STDOUT 17 template<
typename T >
24 throw std::runtime_error(
"failed to read file:\n" + filename );
26 size_t cb = f.tellg();
28 if( cb !=
sizeof(
T ) )
30 <<
"file size (" << cb <<
") does not match data size (" <<
sizeof(
T) <<
"): " << filename );
31 std::vector< T > vec( cb /
sizeof(
T ));
32 f.read( (
char*) data, cb );
55 for(
auto x = 0;
x < 5; ++
x )
72 void reset() { _codes.clear(); }
77 super::on_log( severity, message );
80 auto cch = strlen( message );
81 if( cch < 4 || message[cch - 1] !=
']' )
83 char const *
end = message + cch - 1;
84 char const *
start = end - 1;
85 while( *start !=
'[' )
89 if( --start == message )
92 if( start[-1] !=
' ' )
97 while( param < start )
99 if( *param ==
'{' && ++param < start )
101 char const * param_end =
param;
102 while( *param_end !=
'}' && param_end < start )
104 if( param_end == start || param_end - param < 1 )
106 char const *
value = param_end + 1;
107 char const * value_end =
value;
108 while( *value_end !=
' ' )
110 if( value_end == value )
112 if( value_end - value > 1 && strchr(
".;", value_end[-1] ))
114 std::string param_name( param, param_end - param );
115 std::string param_value( value, value_end - value );
116 if( ! values.empty() )
118 values += param_name;
120 values += param_value;
126 if( ! values.empty() )
127 code +=
'[' + values +
']';
128 if( ! _codes.empty() )
135 int main(
int argc,
char * argv[] )
140 bool debug_mode =
false;
144 for(
int i = 1;
i < argc; ++
i )
148 char const *
dir = argv[
i];
149 if( !strcmp( dir,
"--version" ) )
156 if( ! strcmp( dir,
"--debug" ) || ! strcmp( dir,
"-d" ) )
161 std::cout <<
"Processing: " << dir <<
" ..." << std::endl;
168 catch( std::exception
const &
e )
170 std::cout <<
"!! failed: " << e.what() << std::endl;
173 calibration = old_calibration;
192 throw std::invalid_argument(
"cal.registers file is malformed! (hexdump -v -e '4/ \"%f \"')" );
195 algo::optimizer::settings settings;
200 catch( std::exception
const & e )
202 std::cout <<
"!! failed: " << e.what() <<
" -> assuming [MANUAL LONG 9 @40degC]" << std::endl;
204 settings.hum_temp = 40;
205 settings.is_manual_trigger =
true;
206 settings.receiver_gain = 9;
216 auto vec = read_vector_from< byte >(
join( dir,
"rgb_thermal_table" ) );
217 thermal::l500::thermal_calibration_table thermal_table( vec );
219 auto scale = thermal_table.get_thermal_scale( settings.hum_temp );
221 raw_rgb_intr.
fx = float( raw_rgb_intr.
fx *
scale );
222 raw_rgb_intr.
fy = float( raw_rgb_intr.
fy *
scale );
223 camera.
rgb = raw_rgb_intr;
225 catch( std::exception
const & )
227 AC_LOG( ERROR,
"Could not read raw_rgb.intrinsics or rgb_thermal_table; using rgb.calib [NO-THERMAL]" );
239 "rgb_last_successful.raw",
248 profiler.
section(
"is_scene_valid" );
251 TRACE(
"-E- SCENE_INVALID" );
252 if( ! status.empty() )
254 status +=
"SCENE_INVALID";
258 profiler.
section(
"optimize" );
259 size_t n_iteration = cal.
optimize();
263 profiler.
section(
"is_valid_results" );
266 TRACE(
"NOT VALID\n" );
267 results =
"BAD_RESULT";
271 results =
"SUCCESSFUL";
277 if( ! status.empty() )
282 if( ! status.empty() )
303 if( ! status.empty() )
309 TRACE(
"\n___\nVS:" );
314 TRACE(
"\n___\nSTATUS: " + status );
316 catch( std::exception
const &
e )
318 std::cerr <<
"\n___\ncaught exception: " << e.what() << std::endl;
323 std::cerr <<
"\n___\ncaught unknown exception!" << std::endl;
GLenum GLuint GLenum GLsizei const GLchar * message
rs2_extrinsics_double get_extrinsics() const
void on_log(char severity, char const *message) override
GLenum GLuint GLenum severity
std::string join(const std::string &base, const std::string &path)
librealsense::algo::depth_to_rgb_calibration::algo_calibration_info cal_info
rs2_distortion
Distortion model: defines how pixel coordinates should be mapped to sensor coordinates.
GLenum GLenum GLenum GLenum GLenum scale
rs2_intrinsics_double get_intrinsics() const
GLsizei const GLchar *const * string
status
Defines return codes that SDK interfaces use. Negative values indicate errors, a zero value indicates...
librealsense::algo::depth_to_rgb_calibration::algo_calibration_registers cal_regs
GLint GLenum GLint const GLfloat * coeffs
size_t optimize(std::function< void(data_collect const &data) > iteration_callback=nullptr)
std::string const & get_codes() const
librealsense::algo::depth_to_rgb_calibration::rs2_intrinsics_double z
rs2_dsm_params const & get_dsm_params() const
void read_binary_file(char const *dir, char const *bin, T *data)
void init_algo(algo::optimizer &cal, std::string const &dir, std::string const &yuy, std::string const &yuy_prev, std::string const &yuy_last_successful, std::string const &ir, std::string const &z, camera_params const &camera, memory_profiler *profiler=nullptr)
librealsense::algo::depth_to_rgb_calibration::rs2_extrinsics_double extrinsics
#define AC_LOG(TYPE, MSG)
void validate_dsm_params(struct rs2_dsm_params const &dsm_params)
GLsizei const GLfloat * values
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
rs2_dsm_params dsm_params
bool is_scene_valid(input_validity_data *data=nullptr)
calib const & get_calibration() const
void section(char const *heading)
const char * what() const noexceptoverride
librealsense::algo::depth_to_rgb_calibration::rs2_intrinsics_double rgb
const GLuint GLenum const void * binary
static const textual_icon camera
#define RS2_API_VERSION_STR
int main(int argc, char *argv[])
std::string to_string(T value)