18 template<
typename F,
typename D >
27 if (val_cpp !=
approx(val_matlab))
29 AC_LOG(
DEBUG,
"... " << std::setprecision(16) << compared <<
": {matlab} " << val_matlab <<
" !~ " << val_cpp <<
" {cpp} Diff = " << val_matlab - val_cpp);
51 return dx.alpha ==
approx(
fx.alpha ) &&
60 for(
auto i = 0;
i < 12;
i++ )
72 bool is_equal_approximetly<std::vector<double>, std::vector<double>>(std::vector<double>
fx, std::vector<double> dx,
bool print)
74 if(
fx.size() != dx.size())
77 for (
auto i = 0;
i <
fx.size();
i++)
141 template<
typename F,
typename D >
142 void print(
size_t x, F
f,
D d,
bool is_approx =
false )
145 AC_LOG(
DEBUG,
"... " <<
AC_D_PREC << x <<
": {matlab}" << +f << (is_approx ?
" !~ " :
" != ") << +d <<
"{c++}" );
152 AC_LOG(
DEBUG,
"... " <<
AC_D_PREC << std::fixed <<
x <<
": {matlab}" <<
f.get_fx() <<
" " <<
f.get_fy() <<
" " <<
f.get_ppx() <<
" " <<
f.get_ppy() << (is_approx ?
" !~ " :
" != ")
153 <<
d.get_fx() <<
" " <<
d.get_fy() <<
" " <<
d.get_ppx() <<
" " <<
d.get_ppy() <<
"{c++}" );
160 AC_LOG(
DEBUG,
"... " <<
AC_D_PREC << std::fixed <<
x <<
": {matlab}" <<
f.x <<
" " <<
f.y << (is_approx ?
" !~ " :
" != ")
161 <<
d.x <<
" " <<
d.y <<
"{c++}" );
168 AC_LOG(
DEBUG,
"... " << std::setprecision( 15 ) << std::fixed <<
x <<
": {matlab}" <<
f.x <<
" " <<
f.y <<
" " <<
f.z << (is_approx ?
" !~ " :
" != ")
169 <<
d.x <<
" " <<
d.y <<
" " <<
d.z <<
"{c++}" );
176 AC_LOG(
DEBUG,
"... " << std::setprecision( 15 ) <<
x <<
": {matlab}" <<
f.alpha <<
" " <<
f.beta <<
" " <<
f.gamma << (is_approx ?
" !~ " :
" != ")
177 <<
d.alpha <<
" " <<
d.beta <<
" " <<
d.gamma <<
"{c++}" );
183 std::ostringstream
s;
185 for(
auto i = 0;
i < 12;
i++ )
189 s <<
i <<
": " << std::setprecision( 15 ) << std::fixed <<
": {matlab}" <<
f.vals[
i] << (is_approx ?
" !~ " :
" != ");
190 s << std::setprecision( 15 ) <<
"{c++}" <<
d.vals[
i] <<
"\n";
195 AC_LOG(
DEBUG,
"... " << std::setprecision( 15 ) << std::fixed <<
x <<
" " << s.str() );
199 void print<std::vector<double>, std::vector<double>>(
size_t x, std::vector<double>
f, std::vector<double>
d,
bool is_approx)
201 std::ostringstream
s;
203 for (
auto i = 0;
i <
f.size();
i++)
207 s << i <<
": " << std::setprecision(15) << std::fixed <<
": {matlab}" <<
f[
i] << (is_approx ?
" !~ " :
" != ");
208 s << std::setprecision(15) <<
"{c++}" <<
d[
i] <<
"\n";
213 AC_LOG(
DEBUG,
"... " << std::setprecision(15) << std::fixed <<
x <<
" " << s.str());
217 typename F,
typename D,
225 template<
typename F,
typename D,
234 template<
typename F,
typename D >
237 assert( matlab.size() == cpp.size() );
238 size_t n_mismatches = 0;
239 size_t size = matlab.size();
240 for(
size_t x = 0;
x <
size; ++
x )
246 if( ++n_mismatches <= 5 )
251 AC_LOG(
DEBUG,
"... " << n_mismatches <<
" mismatched values of " << size );
252 return (n_mismatches == 0);
255 template<
typename F,
typename D >
257 std::vector< D >
const & vec,
262 bool( *compare_vectors )(std::vector< F >
const &, std::vector< D >
const &) =
nullptr 265 TRACE(
"Comparing " << filename <<
" ..." );
268 if( bin.size() !=
size)
269 TRACE( filename <<
": {matlab size}" << bin.size() <<
" != {width}" << width <<
"x" << height <<
"{height}" ), ok =
false;
270 if( vec.size() != bin.size() )
271 TRACE( filename <<
": {c++ size}" << vec.size() <<
" != " << bin.size() <<
"{matlab size}" ), ok =
false;
277 if( compare_vectors && !(*compare_vectors)(
b,
v) )
288 template<
typename F,
typename D >
290 std::vector< D >
const & vec,
293 size_t width,
size_t height,
294 bool(*compare_vectors)(std::vector< F >
const &, std::vector< D >
const &) =
nullptr 297 return compare_to_bin_file(vec, scene_dir, filename, width, height, width*height, compare_vectors);
300 template<
typename F,
typename D >
302 std::vector< D >
const & vec,
305 size_t width,
size_t height,
307 bool( *compare_vectors )(std::vector< F >
const &, std::vector< D >
const &) =
nullptr 311 return compare_to_bin_file< F, D >( vec,
312 scene_dir,
bin_file( prefix, width, height, suffix ) +
".bin",
330 auto bin = read_vector_from< double >(
join(
bin_dir( scene_dir ), filename ) );
331 if( bin.size() *
sizeof( double ) != data_size )
333 AC_LOG(
DEBUG,
"... " << filename <<
": {matlab size}" << bin.size() *
sizeof(double) <<
" != " << data_size );
337 auto data = bin.data();
345 cost = *(
double*)(
data);
375 for(
auto i = 0;
i < 9;
i++ )
378 for(
auto i = 0;
i < 3;
i++ )
408 template<
typename D>
415 TRACE(
"Comparing " << filename <<
" ...");
417 auto obj_matlab = read_from< D >(
join(
bin_dir( scene_dir ), filename ) );
428 auto vec = read_vector_from< byte >(
431 std::vector<byte> thermal_vec( 16, 0 );
432 thermal_vec.insert( thermal_vec.end(), vec.begin(), vec.end() );
433 thermal::l500::thermal_calibration_table thermal_table( thermal_vec );
434 scale = thermal_table.get_thermal_scale( hum_temp );
437 catch( std::exception
const & )
rs2_extrinsics_double get_extrinsics() const
GLboolean GLboolean GLboolean b
bool compare_to_bin_file(std::vector< D > const &vec, std::string const &scene_dir, std::string const &filename, size_t width, size_t height, size_t size, bool(*compare_vectors)(std::vector< F > const &, std::vector< D > const &)=nullptr)
bool get_calib_and_cost_from_raw_data(algo::calib &calib, double &cost, std::string const &scene_dir, std::string const &filename)
void print(size_t x, F f, D d, bool is_approx=false)
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)
GLenum GLenum GLenum GLenum GLenum scale
rs2_intrinsics_double get_intrinsics() const
GLsizei const GLchar *const * string
bool read_thermal_data(std::string dir, double hum_temp, double &scale)
bool compare_calib(algo::calib const &calib, double cost, algo::calib calib_from_file, double cost_matlab)
bool compare_same_vectors(std::vector< F > const &matlab, std::vector< D > const &cpp)
bool compare_t(F f, D d, bool print=true)
GLint GLsizei GLsizei height
bool is_equal_approximetly(F fx, D dx, bool print=true)
#define AC_LOG(TYPE, MSG)
bool compare_and_trace(D val_matlab, D val_cpp, std::string const &compared)
std::string bin_dir(std::string const &scene_dir)
bool operator==(const algo::algo_calibration_registers &first, const algo::algo_calibration_registers &second)
std::string to_string(T value)