compare-scene.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 struct scene_stats
5 {
9  double cost, d_cost;
11  size_t n_cycles;
13 };
14 
15 void compare_vertices_to_los_data( std::string const & scene_dir,
16  size_t num_of_vertices,
17  size_t cycle,
18  std::string const & time,
20 {
21 
22  CHECK( compare_to_bin_file< algo::double3 >(
23  data.laser_incident,
24  scene_dir,
25  bin_file( time + "laserIncidentDirection", cycle, 3, 1, "double_00.bin" ) ) );
26 
27  CHECK( compare_to_bin_file< algo::double3 >(
29  scene_dir,
30  bin_file( time + "fovexIndicentDirection", cycle, 3, num_of_vertices, "double_00" )
31  + ".bin",
32  num_of_vertices,
33  1,
35 
36  CHECK( compare_to_bin_file< algo::double3 >(
38  scene_dir,
39  bin_file( time + "mirrorNormalDirection", cycle, 3, num_of_vertices, "double_00" ) + ".bin",
40  num_of_vertices,
41  1,
43 
44  CHECK( compare_to_bin_file< double >(
45  data.ang_x,
46  scene_dir,
47  bin_file( time + "angX", cycle, 1, num_of_vertices, "double_00" ) + ".bin",
48  num_of_vertices,
49  1,
51 
52  CHECK( compare_to_bin_file< double >(
53  data.ang_y,
54  scene_dir,
55  bin_file( time + "angY", cycle, 1, num_of_vertices, "double_00" ) + ".bin",
56  num_of_vertices,
57  1,
59 
60  CHECK( compare_to_bin_file< double >(
61  data.dsm_x_corr,
62  scene_dir,
63  bin_file( time + "dsmXcorr", cycle, 1, num_of_vertices, "double_00" ) + ".bin",
64  num_of_vertices,
65  1,
67 
68  CHECK( compare_to_bin_file< double >(
69  data.dsm_y_corr,
70  scene_dir,
71  bin_file( time + "dsmYcorr", cycle, 1, num_of_vertices, "double_00" ) + ".bin",
72  num_of_vertices,
73  1,
75 
76  CHECK( compare_to_bin_file< double >(
77  data.dsm_x,
78  scene_dir,
79  bin_file( time + "dsmX", cycle, 1, num_of_vertices, "double_00" ) + ".bin",
80  num_of_vertices,
81  1,
83 
84  CHECK( compare_to_bin_file< double >(
85  data.dsm_y,
86  scene_dir,
87  bin_file( time + "dsmY", cycle, 1, num_of_vertices, "double_00" ) + ".bin",
88  num_of_vertices,
89  1,
91 }
92 
93 void compare_preprocessing_data( std::string const & scene_dir,
94  algo::z_frame_data const & depth_data,
95  algo::ir_frame_data const & ir_data,
96  algo::yuy2_frame_data const & yuy_data,
97  scene_metadata const & md )
98 {
99  auto z_w = depth_data.width;
100  auto z_h = depth_data.height;
101 
102  auto rgb_w = yuy_data.width;
103  auto rgb_h = yuy_data.height;
104 
105  // smearing
106  CHECK( compare_to_bin_file< double >( depth_data.gradient_x,
107  scene_dir,
108  "Zx",
109  z_w,
110  z_h,
111  "double_00",
113  CHECK( compare_to_bin_file< double >( depth_data.gradient_y,
114  scene_dir,
115  "Zy",
116  z_w,
117  z_h,
118  "double_00",
120  CHECK( compare_to_bin_file< double >( ir_data.gradient_x,
121  scene_dir,
122  "Ix",
123  z_w,
124  z_h,
125  "double_00",
127  CHECK( compare_to_bin_file< double >( ir_data.gradient_y,
128  scene_dir,
129  "Iy",
130  z_w,
131  z_h,
132  "double_00",
134  CHECK( compare_to_bin_file< double >( ir_data.edges,
135  scene_dir,
136  "iEdge",
137  z_w,
138  z_h,
139  "double_00",
141  CHECK( compare_to_bin_file< double >( depth_data.edges,
142  scene_dir,
143  "zedge",
144  z_w,
145  z_h,
146  "double_00",
148  CHECK( compare_to_bin_file< uint8_t >( depth_data.section_map_depth,
149  scene_dir,
150  "sectionMapDepth",
151  z_w,
152  z_h,
153  "uint8_00",
155  CHECK( compare_to_bin_file< double >( ir_data.valid_edge_pixels_by_ir,
156  scene_dir,
157  "validEdgePixelsByIR",
158  z_w,
159  z_h,
160  "double_00",
162  CHECK( compare_to_bin_file< double >( ir_data.valid_location_rc_x,
163  scene_dir,
164  "gridXValid",
165  1,
166  md.n_valid_ir_edges,
167  "double_00",
169  CHECK( compare_to_bin_file< double >( ir_data.valid_location_rc_y,
170  scene_dir,
171  "gridYValid",
172  1,
173  md.n_valid_ir_edges,
174  "double_00",
176  CHECK( compare_to_bin_file< double >( ir_data.valid_location_rc,
177  scene_dir,
178  "locRC",
179  2,
180  md.n_valid_ir_edges,
181  "double_00",
183  CHECK( compare_to_bin_file< uint8_t >( ir_data.valid_section_map,
184  scene_dir,
185  "sectionMapValid",
186  1,
187  md.n_valid_ir_edges,
188  "uint8_00",
190  CHECK( compare_to_bin_file< double >( ir_data.valid_gradient_x,
191  scene_dir,
192  "IxValid",
193  1,
194  md.n_valid_ir_edges,
195  "double_00",
197  CHECK( compare_to_bin_file< double >( ir_data.valid_gradient_y,
198  scene_dir,
199  "IyValid",
200  1,
201  md.n_valid_ir_edges,
202  "double_00",
204  CHECK( compare_to_bin_file< double >( ir_data.direction_deg,
205  scene_dir,
206  "directionInDeg",
207  1,
208  md.n_valid_ir_edges,
209  "double_00",
211  CHECK( compare_to_bin_file< double >( ir_data.direction_per_pixel,
212  scene_dir,
213  "dirPerPixel",
214  2,
215  md.n_valid_ir_edges,
216  "double_00",
218  CHECK( compare_to_bin_file< double >( ir_data.local_region[0],
219  scene_dir,
220  "localRegion",
221  2,
222  md.n_valid_ir_edges,
223  "double_00",
225  CHECK( compare_to_bin_file< double >( ir_data.local_region[1],
226  scene_dir,
227  "localRegion",
228  2,
229  md.n_valid_ir_edges,
230  "double_01",
232  CHECK( compare_to_bin_file< double >( ir_data.local_region[2],
233  scene_dir,
234  "localRegion",
235  2,
236  md.n_valid_ir_edges,
237  "double_02",
239  CHECK( compare_to_bin_file< double >( ir_data.local_region[3],
240  scene_dir,
241  "localRegion",
242  2,
243  md.n_valid_ir_edges,
244  "double_03",
246  CHECK( compare_to_bin_file< double >( ir_data.local_region_x[0],
247  scene_dir,
248  "localRegion_x",
249  1,
250  md.n_valid_ir_edges,
251  "double_00",
253  CHECK( compare_to_bin_file< double >( ir_data.local_region_x[1],
254  scene_dir,
255  "localRegion_x",
256  1,
257  md.n_valid_ir_edges,
258  "double_01",
260  CHECK( compare_to_bin_file< double >( ir_data.local_region_x[2],
261  scene_dir,
262  "localRegion_x",
263  1,
264  md.n_valid_ir_edges,
265  "double_02",
267  CHECK( compare_to_bin_file< double >( ir_data.local_region_x[3],
268  scene_dir,
269  "localRegion_x",
270  1,
271  md.n_valid_ir_edges,
272  "double_03",
274  CHECK( compare_to_bin_file< double >( ir_data.local_region_y[0],
275  scene_dir,
276  "localRegion_y",
277  1,
278  md.n_valid_ir_edges,
279  "double_00",
281  CHECK( compare_to_bin_file< double >( ir_data.local_region_y[1],
282  scene_dir,
283  "localRegion_y",
284  1,
285  md.n_valid_ir_edges,
286  "double_01",
288  CHECK( compare_to_bin_file< double >( ir_data.local_region_y[2],
289  scene_dir,
290  "localRegion_y",
291  1,
292  md.n_valid_ir_edges,
293  "double_02",
295  CHECK( compare_to_bin_file< double >( ir_data.local_region_y[3],
296  scene_dir,
297  "localRegion_y",
298  1,
299  md.n_valid_ir_edges,
300  "double_03",
302  CHECK( compare_to_bin_file< double >( ir_data.local_edges,
303  scene_dir,
304  "localEdges",
305  4,
306  md.n_valid_ir_edges,
307  "double_00",
309  CHECK( compare_to_bin_file< uint8_t >( ir_data.is_supressed,
310  scene_dir,
311  "isSupressed",
312  1,
313  md.n_valid_ir_edges,
314  "uint8_00",
316  CHECK( compare_to_bin_file< double >( ir_data.fraq_step,
317  scene_dir,
318  "fraqStep",
319  1,
320  md.n_valid_ir_edges,
321  "double_00",
323  CHECK( compare_to_bin_file< double >( depth_data.local_rc_subpixel,
324  scene_dir,
325  "locRCsub",
326  2,
327  md.n_valid_ir_edges,
328  "double_00",
330  CHECK( compare_to_bin_file< double >( depth_data.local_x,
331  scene_dir,
332  "localZx",
333  2,
334  md.n_valid_ir_edges,
335  "double_00",
337  CHECK( compare_to_bin_file< double >( depth_data.local_y,
338  scene_dir,
339  "localZy",
340  2,
341  md.n_valid_ir_edges,
342  "double_00",
344  CHECK( compare_to_bin_file< double >( depth_data.gradient,
345  scene_dir,
346  "zGrad",
347  2,
348  md.n_valid_ir_edges,
349  "double_00",
351  CHECK( compare_to_bin_file< double >( depth_data.grad_in_direction,
352  scene_dir,
353  "zGradInDirection",
354  1,
355  md.n_valid_ir_edges,
356  "double_00",
358  CHECK( compare_to_bin_file< double >( depth_data.local_values,
359  scene_dir,
360  "localZvalues",
361  4,
362  md.n_valid_ir_edges,
363  "double_00",
365  CHECK( compare_to_bin_file< double >( depth_data.closest,
366  scene_dir,
367  "zValuesForSubEdges",
368  1,
369  md.n_edges,
370  "double_00",
372  CHECK( compare_to_bin_file< double >( depth_data.edge_sub_pixel,
373  scene_dir,
374  "edgeSubPixel",
375  2,
376  md.n_valid_ir_edges,
377  "double_00",
379 
380  CHECK( compare_to_bin_file< byte >( depth_data.supressed_edges,
381  scene_dir,
382  "validEdgePixels",
383  1,
384  md.n_valid_ir_edges,
385  "uint8_00",
387  CHECK( compare_to_bin_file< double >( depth_data.grad_in_direction_valid,
388  scene_dir,
389  "validzGradInDirection",
390  1,
391  md.n_valid_pixels,
392  "double_00",
394  CHECK( compare_to_bin_file< double >( depth_data.valid_edge_sub_pixel,
395  scene_dir,
396  "validedgeSubPixel",
397  2,
398  md.n_valid_pixels,
399  "double_00",
401  CHECK( compare_to_bin_file< double >( depth_data.values_for_subedges,
402  scene_dir,
403  "validzValuesForSubEdges",
404  1,
405  md.n_valid_pixels,
406  "double_00",
408  CHECK( compare_to_bin_file< double >( depth_data.valid_direction_per_pixel,
409  scene_dir,
410  "validdirPerPixel",
411  1,
412  md.n_valid_pixels,
413  "double_00",
415  CHECK( compare_to_bin_file< uint8_t >( depth_data.valid_section_map,
416  scene_dir,
417  "validsectionMapDepth",
418  1,
419  md.n_valid_pixels,
420  "uint8_00",
422  CHECK( compare_to_bin_file< double >( depth_data.valid_directions,
423  scene_dir,
424  "validdirectionIndex",
425  1,
426  md.n_valid_pixels,
427  "double_00",
429  CHECK( compare_to_bin_file< algo::k_matrix >(
430  depth_data.k_depth_pinv,
431  scene_dir,
432  bin_file( "k_depth_pinv", 3, 3, "double_00.bin" ) ) );
433  // CHECK(compare_to_bin_file< double >(depth_data.valid_edge_sub_pixel_x, scene_dir, "xim", 1,
434  // md.n_valid_pixels, "double_00", compare_same_vectors)); CHECK(compare_to_bin_file< double
435  // >(depth_data.valid_edge_sub_pixel_y, scene_dir, "yim", 1, md.n_valid_pixels, "double_00",
436  // compare_same_vectors));
437  CHECK( compare_to_bin_file< double >( depth_data.sub_points,
438  scene_dir, "subPoints",
439  3, md.n_valid_pixels,
440  "double_00",
442  CHECK( compare_to_bin_file< algo::double2 >( depth_data.uvmap,
443  scene_dir,
444  bin_file( "uv", 2, md.n_valid_pixels, "double_00" )
445  + ".bin",
446  md.n_valid_pixels, 1,
448  CHECK( compare_to_bin_file< byte >( depth_data.is_inside,
449  scene_dir, "isInside",
450  1, md.n_valid_pixels,
451  "uint8_00",
453  CHECK( compare_to_bin_file< double >( depth_data.subpixels_x,
454  scene_dir, "Z_xim",
455  1, md.n_edges,
456  "double_00",
458  CHECK( compare_to_bin_file< double >( depth_data.subpixels_y,
459  scene_dir, "Z_yim",
460  1, md.n_edges,
461  "double_00",
463  CHECK( compare_to_bin_file< double >( depth_data.directions,
464  scene_dir, "directionIndexInside",
465  1, md.n_edges,
466  "double_00",
468 
469  CHECK( compare_to_bin_file< double >( depth_data.subpixels_x_round,
470  scene_dir, "round_xim",
471  1, md.n_edges,
472  "double_00",
474  CHECK( compare_to_bin_file< double >( depth_data.subpixels_y_round,
475  scene_dir, "round_yim",
476  1, md.n_edges,
477  "double_00",
479  CHECK( compare_to_bin_file< double >( depth_data.weights,
480  scene_dir, "weights",
481  1, md.n_edges,
482  "double_00",
484  CHECK( compare_to_bin_file< uint8_t >( depth_data.relevant_pixels_image,
485  scene_dir, "relevantPixelsImage",
486  z_w, z_h,
487  "uint8_00",
489  CHECK( compare_to_bin_file< algo::double3 >( depth_data.vertices,
490  scene_dir,
491  bin_file( "vertices", 3, md.n_edges, "double_00" )
492  + ".bin",
493  md.n_edges, 1,
495  CHECK( compare_to_bin_file< uint8_t >( depth_data.section_map,
496  scene_dir, "sectionMapDepthInside",
497  1, md.n_edges,
498  "uint8_00",
500 
501  CHECK( compare_to_bin_file< uint8_t >( yuy_data.debug.lum_frame,
502  scene_dir, "YUY2_lum",
503  rgb_w, rgb_h,
504  "uint8_00",
506  CHECK( compare_to_bin_file< double >( yuy_data.debug.edges,
507  scene_dir, "YUY2_edge",
508  rgb_w, rgb_h,
509  "double_00",
511  CHECK( compare_to_bin_file< double >( yuy_data.edges_IDT,
512  scene_dir, "YUY2_IDT",
513  rgb_w, rgb_h,
514  "double_00",
516  CHECK( compare_to_bin_file< double >( yuy_data.edges_IDTx,
517  scene_dir, "YUY2_IDTx",
518  rgb_w, rgb_h,
519  "double_00",
521  CHECK( compare_to_bin_file< double >( yuy_data.edges_IDTy,
522  scene_dir, "YUY2_IDTy",
523  rgb_w, rgb_h,
524  "double_00",
526 }
527 
528 
529 void compare_scene( std::string const & scene_dir,
530  bool debug_mode = true,
531  scene_stats * stats = nullptr )
532 {
533  TRACE( "Loading " << scene_dir << " ..." );
534 
535  memory_profiler profiler;
536 
537  camera_params ci = read_camera_params( scene_dir, "camera_params" );
538  dsm_params dsm = read_dsm_params( scene_dir, "DSM_params" );
539  ci.dsm_params = dsm.params;
540  ci.cal_info = dsm.regs;
542 
543  scene_metadata md( scene_dir );
544 
545  algo::optimizer::settings settings;
546  read_data_from( join( bin_dir( scene_dir ), "settings" ), &settings );
547 
548  auto scale = 1.;
549  if (read_thermal_data(scene_dir,
550  settings.hum_temp, scale))
551  {
552  ci.rgb.fx *= scale;
553  ci.rgb.fy *= scale;
554 
555  auto filename = bin_file( "Kthermal_rgb", 9, 1, "double_00" ) + ".bin";
556  TRACE( "Comparing " << filename << " ..." );
557  CHECK( compare_to_bin_file( algo::k_matrix( ci.rgb ), scene_dir, filename ) );
558  }
559  else
560  {
561  TRACE( "No thermal data found" );
562  }
563 
564  algo::optimizer cal( settings, debug_mode );
565  init_algo( cal,
566  scene_dir,
567  md.rgb_file,
568  md.rgb_prev_file,
570  md.ir_file,
571  md.z_file,
572  ci,
573  &profiler );
574 
575  auto & z_data = cal.get_z_data();
576  auto & ir_data = cal.get_ir_data();
577  auto & yuy_data = cal.get_yuy_data();
578  auto & depth_data = cal.get_z_data();
579  auto & decision_params = cal.get_decision_params();
580  auto & svm_features = cal.get_extracted_features();
581 
582  auto rgb_h = ci.rgb.height;
583  auto rgb_w = ci.rgb.width;
584  auto z_h = ci.z.height;
585  auto z_w = ci.z.width;
586  auto num_of_calib_elements = 22;
587  auto num_of_p_matrix_elements = sizeof( algo::p_matrix ) / sizeof( double );
588  auto num_of_k_matrix_elements = sizeof( algo::k_matrix ) / sizeof( double );
589 
590  if( debug_mode )
591  compare_preprocessing_data( scene_dir, z_data, ir_data, yuy_data, md );
592 
593  // ---
594 
596  profiler.section( "Checking scene validity" );
597  bool const is_scene_valid = cal.is_scene_valid( debug_mode ? &data : nullptr );
598  profiler.section_end();
599 
600  bool const matlab_scene_valid = md.is_scene_valid;
601  CHECK( is_scene_valid == matlab_scene_valid );
602  if( debug_mode )
603  {
604  bool spread
605  = read_from< uint8_t >( join( bin_dir( scene_dir ), "DirSpread_1x1_uint8_00.bin" ) );
606  CHECK( data.edges_dir_spread == spread );
607  bool rgbEdgesSpread = read_from< uint8_t >(
608  join( bin_dir( scene_dir ), "rgbEdgesSpread_1x1_uint8_00.bin" ) );
609  CHECK( data.rgb_spatial_spread == rgbEdgesSpread );
610  bool depthEdgesSpread = read_from< uint8_t >(
611  join( bin_dir( scene_dir ), "depthEdgesSpread_1x1_uint8_00.bin" ) );
612  CHECK( data.depth_spatial_spread == depthEdgesSpread );
613  bool isMovementFromLastSuccess = read_from< uint8_t >(
614  join( bin_dir( scene_dir ), "isMovementFromLastSuccess_1x1_uint8_00.bin" ) );
615  CHECK( data.is_movement_from_last_success == isMovementFromLastSuccess );
616  }
617  if( stats )
618  {
619  stats->n_valid_scene = is_scene_valid;
620  stats->n_valid_scene_diff = is_scene_valid != matlab_scene_valid;
621  }
622 
623  // edge distribution
624  CHECK( compare_to_bin_file< double >( z_data.sum_weights_per_section,
625  scene_dir,
626  "depthEdgeWeightDistributionPerSectionDepth",
627  1,
628  4,
629  "double_00",
631 
632  // CHECK( compare_to_bin_file< byte >( z_data.section_map, scene_dir, "sectionMapDepth_trans",
633  // 1, md.n_edges, "uint8_00", compare_same_vectors ) ); CHECK( compare_to_bin_file< byte >(
634  // yuy_data.section_map, scene_dir, "sectionMapRgb_trans", 1, rgb_w*rgb_h, "uint8_00",
635  // compare_same_vectors ) );
636 
637  CHECK( compare_to_bin_file< double >( yuy_data.sum_weights_per_section,
638  scene_dir,
639  "edgeWeightDistributionPerSectionRgb",
640  1,
641  4,
642  "double_00",
644 
645  // gradient balanced
646  // TODO NOHA
647  CHECK( compare_to_bin_file< double >( z_data.sum_weights_per_direction,
648  scene_dir,
649  "edgeWeightsPerDir",
650  4,
651  1,
652  "double_00",
654 
655  // movment check
656  // 1. dilation
657  if( debug_mode )
658  CHECK( compare_to_bin_file< uint8_t >( yuy_data.debug.movement_result.logic_edges,
659  scene_dir, "logicEdges",
660  rgb_w, rgb_h,
661  "uint8_00",
663  if( debug_mode )
664  CHECK( compare_to_bin_file< double >( yuy_data.debug.movement_result.dilated_image,
665  scene_dir, "dilatedIm",
666  rgb_w, rgb_h,
667  "double_00",
669 
670  // 2. gausssian
671  if( debug_mode )
672  CHECK( compare_to_bin_file< double >( yuy_data.debug.movement_result.yuy_diff,
673  scene_dir, "diffIm_01",
674  rgb_w, rgb_h,
675  "double_00",
677  if( debug_mode )
678  CHECK( compare_to_bin_file< double >( yuy_data.debug.movement_result.gaussian_filtered_image,
679  scene_dir, "diffIm",
680  rgb_w, rgb_h,
681  "double_00",
683 
684  // 3. movement
685  if( debug_mode )
686  CHECK( compare_to_bin_file< double >( yuy_data.debug.movement_result.gaussian_diff_masked,
687  scene_dir, "IDiffMasked",
688  rgb_w, rgb_h,
689  "double_00",
691  if( debug_mode )
692  CHECK( compare_to_bin_file< uint8_t >( yuy_data.debug.movement_result.move_suspect,
693  scene_dir, "ixMoveSuspect",
694  rgb_w, rgb_h,
695  "uint8_00",
697 
698  //--
699 
700  auto cb = [&]( algo::data_collect const & data ) {
701  // data.iteration_data_p is 0-based!
702  // REQUIRE( data.iteration_data_p < md.n_iterations );
703 
704  // REQUIRE( data.cycle <= md.n_cycles );
705 
706  if( data.type == algo::k_to_dsm_data )
707  {
708  std::cout << std::endl
709  << "COMPARING K_TO_DSM DATA " << data.cycle_data_p.cycle << std::endl;
710  algo::k_matrix old_k = data.k2dsm_data_p.inputs.old_k;
711  algo::k_matrix new_k = data.k2dsm_data_p.inputs.new_k;
712 
713  CHECK( compare_to_bin_file< double >(
714  std::vector< double >( std::begin( old_k.k_mat.rot ), std::end( old_k.k_mat.rot ) ),
715  scene_dir,
716  bin_file( "k2dsm_inpus_oldKdepth",
717  data.cycle_data_p.cycle,
718  num_of_k_matrix_elements,
719  1,
720  "double_00.bin" ),
721  num_of_k_matrix_elements,
722  1,
724 
725  CHECK( compare_to_bin_file< double >(
726  std::vector< double >( std::begin( new_k.k_mat.rot ), std::end( new_k.k_mat.rot ) ),
727  scene_dir,
728  bin_file( "k2dsm_inpus_newKdepth",
729  data.cycle_data_p.cycle,
730  num_of_k_matrix_elements,
731  1,
732  "double_00.bin" ),
733  num_of_k_matrix_elements,
734  1,
736 
737  CHECK( compare_to_bin_file< algo::double3 >( data.k2dsm_data_p.inputs.z.vertices,
738  scene_dir,
739  bin_file( "k2dsm_inpus_vertices",
740  data.cycle_data_p.cycle,
741  3,
742  md.n_edges,
743  "double_00.bin" ),
744  md.n_edges,
745  1,
747 
748  CHECK( compare_to_bin_file< algo::double2 >(
749  std::vector< algo::double2 >(
750  1,
751  { data.k2dsm_data_p.inputs.previous_dsm_params.h_scale,
752  data.k2dsm_data_p.inputs.previous_dsm_params.v_scale } ),
753  scene_dir,
754  bin_file( "k2dsm_inpus_acData", data.cycle_data_p.cycle, 2, 1, "double_00.bin" ),
755  1,
756  1,
758 
759 
760  CHECK( compare_to_bin_file< algo::algo_calibration_registers >(
761  data.k2dsm_data_p.inputs.new_dsm_regs,
762  scene_dir,
763  bin_file( "k2dsm_inpus_dsmRegs",
764  data.cycle_data_p.cycle,
765  4,
766  1,
767  "double_00.bin" ) ) );
768 
769 
770  CHECK( compare_to_bin_file< algo::algo_calibration_registers >(
771  data.k2dsm_data_p.dsm_regs_orig,
772  scene_dir,
773  bin_file( "dsmRegsOrig", data.cycle_data_p.cycle, 4, 1, "double_00.bin" ) ) );
774 
775  CHECK( compare_to_bin_file< uint8_t >(
776  data.k2dsm_data_p.relevant_pixels_image_rot,
777  scene_dir,
778  bin_file( "relevantPixelnImage_rot", data.cycle_data_p.cycle, z_w, z_h, "uint8_00" )
779  + ".bin",
780  z_w,
781  z_h,
783 
784  CHECK( compare_to_bin_file< algo::los_shift_scaling >(
785  data.k2dsm_data_p.dsm_pre_process_data.last_los_error,
786  scene_dir,
787  bin_file( "dsm_los_error_orig",
788  data.cycle_data_p.cycle,
789  1,
790  4,
791  "double_00.bin" ) ) );
792 
793  CHECK( compare_to_bin_file< algo::double3 >(
794  data.k2dsm_data_p.dsm_pre_process_data.vertices_orig,
795  scene_dir,
796  bin_file( "verticesOrig",
797  data.cycle_data_p.cycle,
798  3,
800  "double_00" )
801  + ".bin",
803  1,
805 
806 
807  compare_vertices_to_los_data( scene_dir,
809  data.cycle_data_p.cycle,
810  "first_",
811  data.k2dsm_data_p.first_norm_vertices_to_los_data );
812 
813  CHECK( compare_to_bin_file< algo::double2 >(
814  data.k2dsm_data_p.dsm_pre_process_data.los_orig,
815  scene_dir,
816  bin_file( "losOrig", data.cycle_data_p.cycle, 2, md.n_relevant_pixels, "double_00" )
817  + ".bin",
819  1,
821 
822  CHECK( compare_to_bin_file< double >( data.k2dsm_data_p.errL2,
823  scene_dir,
824  bin_file( "errL2",
825  data.cycle_data_p.cycle,
826  1,
827  data.k2dsm_data_p.errL2.size(),
828  "double_00" )
829  + ".bin",
830  data.k2dsm_data_p.errL2.size(),
831  1,
833 
834  CHECK( compare_to_bin_file< algo::double2 >(
835  data.k2dsm_data_p.focal_scaling,
836  scene_dir,
837  bin_file( "focalScaling", data.cycle_data_p.cycle, 2, 1, "double_00.bin" ) ) );
838 
839  CHECK( compare_to_bin_file< std::vector< double > >(
840  data.k2dsm_data_p.sg_mat,
841  scene_dir,
842  bin_file( "sgMat",
843  data.cycle_data_p.cycle,
844  data.k2dsm_data_p.sg_mat[0].size(),
845  data.k2dsm_data_p.sg_mat.size(),
846  "double_00" )
847  + ".bin",
848  data.k2dsm_data_p.sg_mat.size(),
849  data.k2dsm_data_p.sg_mat[0].size(),
850  data.k2dsm_data_p.sg_mat.size(),
852 
853  CHECK( compare_to_bin_file< double >(
854  data.k2dsm_data_p.sg_mat_tag_x_sg_mat,
855  scene_dir,
856  bin_file( "sg_mat_tag_x_sg_mat",
857  data.cycle_data_p.cycle,
858  1,
859  data.k2dsm_data_p.sg_mat_tag_x_sg_mat.size(),
860  "double_00" )
861  + ".bin",
862  data.k2dsm_data_p.sg_mat_tag_x_sg_mat.size(),
863  1,
865 
866  CHECK( compare_to_bin_file< double >(
867  data.k2dsm_data_p.sg_mat_tag_x_err_l2,
868  scene_dir,
869  bin_file( "sg_mat_tag_x_err_l2",
870  data.cycle_data_p.cycle,
871  1,
872  data.k2dsm_data_p.sg_mat_tag_x_err_l2.size(),
873  "double_00" )
874  + ".bin",
875  data.k2dsm_data_p.sg_mat_tag_x_err_l2.size(),
876  1,
878 
879  CHECK( compare_to_bin_file< double >( data.k2dsm_data_p.quad_coef,
880  scene_dir,
881  bin_file( "quadCoef",
882  data.cycle_data_p.cycle,
883  1,
884  data.k2dsm_data_p.quad_coef.size(),
885  "double_00" )
886  + ".bin",
887  data.k2dsm_data_p.quad_coef.size(),
888  1,
890 
891  CHECK( compare_to_bin_file< algo::double2 >(
892  data.k2dsm_data_p.opt_scaling_1,
893  scene_dir,
894  bin_file( "optScaling1", data.cycle_data_p.cycle, 1, 2, "double_00.bin" ) ) );
895 
896  CHECK( compare_to_bin_file< algo::double2 >(
897  data.k2dsm_data_p.opt_scaling,
898  scene_dir,
899  bin_file( "optScaling", data.cycle_data_p.cycle, 1, 2, "double_00.bin" ) ) );
900 
901  CHECK( compare_to_bin_file< algo::double2 >(
902  data.k2dsm_data_p.new_los_scaling,
903  scene_dir,
904  bin_file( "newlosScaling", data.cycle_data_p.cycle, 1, 2, "double_00.bin" ) ) );
905 
906  CHECK( compare_to_bin_file< algo::double2 >(
907  std::vector< algo::double2 >( 1,
908  { data.k2dsm_data_p.dsm_params_cand.h_scale,
909  data.k2dsm_data_p.dsm_params_cand.v_scale } ),
910  scene_dir,
911  bin_file( "acDataCand", data.cycle_data_p.cycle, 2, 1, "double_00.bin" ),
912  1,
913  1,
915 
916  CHECK( compare_to_bin_file< algo::algo_calibration_registers >(
917  data.k2dsm_data_p.dsm_regs_cand,
918  scene_dir,
919  bin_file( "dsmRegsCand", data.cycle_data_p.cycle, 4, 1, "double_00.bin" ) ) );
920 
921  compare_vertices_to_los_data( scene_dir,
922  md.n_edges,
923  data.cycle_data_p.cycle,
924  "second_",
925  data.k2dsm_data_p.second_norm_vertices_to_los_data );
926 
927  CHECK( compare_to_bin_file< algo::double2 >(
928  data.k2dsm_data_p.los_orig,
929  scene_dir,
930  bin_file( "orig_los", data.cycle_data_p.cycle, 2, md.n_edges, "double_00" )
931  + ".bin",
932  md.n_edges,
933  1,
935 
936  CHECK( compare_to_bin_file< algo::double2 >(
937  data.k2dsm_data_p.dsm,
938  scene_dir,
939  bin_file( "dsm", data.cycle_data_p.cycle, 2, md.n_edges, "double_00" ) + ".bin",
940  md.n_edges,
941  1,
943 
944  CHECK( compare_to_bin_file< algo::double3 >(
945  data.k2dsm_data_p.vertices,
946  scene_dir,
947  bin_file( "new_vertices", data.cycle_data_p.cycle, 3, md.n_edges, "double_00.bin" ),
948  md.n_edges,
949  1,
951 
952  TRACE( "\nSet next cycle data from Matlab:" );
953  }
954  else if( data.type == algo::cycle_data )
955  {
956  std::cout << std::endl
957  << "COMPARING CYCLE DATA " << data.cycle_data_p.cycle << std::endl;
958 
959  algo::k_matrix k_depth;
960  k_depth.k_mat.rot[0] = data.cycle_data_p.new_k_depth.fx;
961  k_depth.k_mat.rot[2] = data.cycle_data_p.new_k_depth.ppx;
962  k_depth.k_mat.rot[4] = data.cycle_data_p.new_k_depth.fy;
963  k_depth.k_mat.rot[5] = data.cycle_data_p.new_k_depth.ppy;
964 
965  CHECK( compare_to_bin_file< algo::k_matrix >(
966  k_depth,
967  scene_dir,
968  bin_file( "end_cycle_Kdepth", data.cycle_data_p.cycle, 3, 3, "double_00.bin" ) ) );
969 
970  CHECK( compare_to_bin_file< algo::p_matrix >( data.cycle_data_p.new_params.curr_p_mat,
971  scene_dir,
972  bin_file( "end_cycle_p_matrix",
973  data.cycle_data_p.cycle,
974  num_of_p_matrix_elements,
975  1,
976  "double_00.bin" ) ) );
977 
978  try
979  {
980 
981  /* auto vertices = read_vector_from<algo::double3>(bin_file(bin_dir(scene_dir) +
982  "end_cycle_vertices", data.cycle_data_p.cycle, 3, md.n_edges, "double_00.bin"));
983 
984  algo::p_matrix p_mat;
985 
986  auto p_vec = read_vector_from<double>(bin_file(bin_dir(scene_dir) +
987  "end_cycle_p_matrix", data.cycle_data_p.cycle, num_of_p_matrix_elements, 1,
988  "double_00.bin"));
989  std::copy(p_vec.begin(), p_vec.end(), p_mat.vals);
990 
991  auto dsm_regs_vec = read_vector_from< algo::algo_calibration_registers >(
992  bin_file(bin_dir(scene_dir) + "end_cycle_dsmRegsCand", data.cycle_data_p.cycle,
993  4, 1, "double_00.bin"));
994 
995  algo::algo_calibration_registers dsm_regs =
996  *(algo::algo_calibration_registers*)(dsm_regs_vec.data()); auto ac_data_vec =
997  read_vector_from< algo::double2 >(bin_file(bin_dir(scene_dir) + "end_cycle_acData",
998  data.cycle_data_p.cycle, 2, 1, "double_00.bin"));
999 
1000  algo::rs2_dsm_params_double dsm_params;
1001  dsm_params.h_scale = ac_data_vec[0].x;
1002  dsm_params.v_scale = ac_data_vec[0].y;
1003  dsm_params.model = RS2_DSM_CORRECTION_AOT;*/
1004 
1005  // auto Kdepth = read_vector_from<algo::matrix_3x3>(bin_file(bin_dir(scene_dir) +
1006  // "end_cycle_Kdepth", data.cycle_data_p.cycle, 3, 3, "double_00.bin"));
1007  // cal.set_cycle_data(vertices, k_depth, p_mat, dsm_regs, dsm_params);
1008  }
1009  catch( std::runtime_error & e )
1010  {
1011  // if device isn't calibrated, get_extrinsics must error out (according to old
1012  // comment. Might not be true under new API)
1013  WARN( e.what() );
1014  }
1015  }
1016  else if( data.type == algo::iteration_data )
1017  {
1018  std::cout << std::endl
1019  << "COMPARING ITERATION DATA " << data.cycle_data_p.cycle << " "
1020  << data.iteration_data_p.iteration + 1 << std::endl;
1021  CHECK( compare_to_bin_file< algo::p_matrix >(
1022  data.iteration_data_p.params.curr_p_mat,
1023  scene_dir,
1024  bin_file( "p_matrix_iteration",
1025  data.cycle_data_p.cycle,
1026  data.iteration_data_p.iteration + 1,
1027  num_of_p_matrix_elements,
1028  1,
1029  "double_00.bin" ) ) );
1030 
1031  CHECK( compare_to_bin_file< double >(
1032  std::vector< double >( std::begin( data.iteration_data_p.c.k_mat.k_mat.rot ),
1033  std::end( data.iteration_data_p.c.k_mat.k_mat.rot ) ),
1034  scene_dir,
1035  bin_file( "Krgb_iteration",
1036  data.cycle_data_p.cycle,
1037  data.iteration_data_p.iteration + 1,
1038  9,
1039  1,
1040  "double_00.bin" ),
1041  9,
1042  1,
1044 
1045  CHECK( compare_to_bin_file< double >(
1046  std::vector< double >( 1, data.iteration_data_p.params.cost ),
1047  scene_dir,
1048  bin_file( "cost_iteration",
1049  data.cycle_data_p.cycle,
1050  data.iteration_data_p.iteration + 1,
1051  1,
1052  1,
1053  "double_00.bin" ),
1054  1,
1055  1,
1057 
1058  CHECK(
1059  compare_to_bin_file< algo::double2 >( data.iteration_data_p.uvmap,
1060  scene_dir,
1061  bin_file( "uvmap_iteration",
1062  data.cycle_data_p.cycle,
1063  data.iteration_data_p.iteration + 1,
1064  2,
1065  md.n_edges,
1066  "double_00.bin" ),
1067  md.n_edges,
1068  1,
1070 
1071  CHECK( compare_to_bin_file< double >( data.iteration_data_p.d_vals,
1072  scene_dir,
1073  bin_file( "DVals_iteration",
1074  data.cycle_data_p.cycle,
1075  data.iteration_data_p.iteration + 1,
1076  1,
1077  md.n_edges,
1078  "double_00.bin" ),
1079  md.n_edges,
1080  1,
1082 
1083  CHECK( compare_to_bin_file< double >( data.iteration_data_p.d_vals_x,
1084  scene_dir,
1085  bin_file( "DxVals_iteration",
1086  data.cycle_data_p.cycle,
1087  data.iteration_data_p.iteration + 1,
1088  1,
1089  md.n_edges,
1090  "double_00.bin" ),
1091  md.n_edges,
1092  1,
1094 
1095  CHECK( compare_to_bin_file< double >( data.iteration_data_p.d_vals_y,
1096  scene_dir,
1097  bin_file( "DyVals_iteration",
1098  data.cycle_data_p.cycle,
1099  data.iteration_data_p.iteration + 1,
1100  1,
1101  md.n_edges,
1102  "double_00.bin" ),
1103  md.n_edges,
1104  1,
1106 
1107  CHECK(
1108  compare_to_bin_file< algo::double2 >( data.iteration_data_p.xy,
1109  scene_dir,
1110  bin_file( "xy_iteration",
1111  data.cycle_data_p.cycle,
1112  data.iteration_data_p.iteration + 1,
1113  2,
1114  md.n_edges,
1115  "double_00.bin" ),
1116  md.n_edges,
1117  1,
1119 
1120  CHECK( compare_to_bin_file< double >( data.iteration_data_p.rc,
1121  scene_dir,
1122  bin_file( "rc_iteration",
1123  data.cycle_data_p.cycle,
1124  data.iteration_data_p.iteration + 1,
1125  1,
1126  md.n_edges,
1127  "double_00.bin" ),
1128  md.n_edges,
1129  1,
1131 
1132  CHECK( compare_to_bin_file< algo::p_matrix >(
1133  data.iteration_data_p.coeffs_p.x_coeffs,
1134  scene_dir,
1135  bin_file( "xCoeff_P_iteration",
1136  data.cycle_data_p.cycle,
1137  data.iteration_data_p.iteration + 1,
1138  num_of_p_matrix_elements,
1139  md.n_edges,
1140  "double_00.bin" ),
1141  md.n_edges,
1142  1,
1144 
1145  CHECK( compare_to_bin_file< algo::p_matrix >(
1146  data.iteration_data_p.coeffs_p.y_coeffs,
1147  scene_dir,
1148  bin_file( "yCoeff_P_iteration",
1149  data.cycle_data_p.cycle,
1150  data.iteration_data_p.iteration + 1,
1151  num_of_p_matrix_elements,
1152  md.n_edges,
1153  "double_00.bin" ),
1154  md.n_edges,
1155  1,
1157 
1158  CHECK( compare_to_bin_file< double >(
1159  std::vector< double >(
1160  std::begin( data.iteration_data_p.params.calib_gradients.vals ),
1161  std::end( data.iteration_data_p.params.calib_gradients.vals ) ),
1162  scene_dir,
1163  bin_file( "grad_iteration",
1164  data.cycle_data_p.cycle,
1165  data.iteration_data_p.iteration + 1,
1166  num_of_p_matrix_elements,
1167  1,
1168  "double_00.bin" ),
1169  num_of_p_matrix_elements,
1170  1,
1172 
1173  CHECK( compare_to_bin_file< double >(
1174  std::vector< double >( 1, data.iteration_data_p.grads_norma ),
1175  scene_dir,
1176  bin_file( "grad_norma_iteration",
1177  data.cycle_data_p.cycle,
1178  data.iteration_data_p.iteration + 1,
1179  1,
1180  1,
1181  "double_00.bin" ),
1182  1,
1183  1,
1185 
1186  CHECK( compare_to_bin_file< double >(
1187  std::vector< double >( std::begin( data.iteration_data_p.grads_norm.vals ),
1188  std::end( data.iteration_data_p.grads_norm.vals ) ),
1189  scene_dir,
1190  bin_file( "grads_norm_iteration",
1191  data.cycle_data_p.cycle,
1192  data.iteration_data_p.iteration + 1,
1193  num_of_p_matrix_elements,
1194  1,
1195  "double_00.bin" ),
1196  num_of_p_matrix_elements,
1197  1,
1199 
1200 
1201  CHECK( compare_to_bin_file< double >(
1202  std::vector< double >( std::begin( data.iteration_data_p.normalized_grads.vals ),
1203  std::end( data.iteration_data_p.normalized_grads.vals ) ),
1204  scene_dir,
1205  bin_file( "normalized_grads_iteration",
1206  data.cycle_data_p.cycle,
1207  data.iteration_data_p.iteration + 1,
1208  num_of_p_matrix_elements,
1209  1,
1210  "double_00.bin" ),
1211  num_of_p_matrix_elements,
1212  1,
1214 
1215 
1216  CHECK( compare_to_bin_file< double >(
1217  std::vector< double >( std::begin( data.iteration_data_p.unit_grad.vals ),
1218  std::end( data.iteration_data_p.unit_grad.vals ) ),
1219  scene_dir,
1220  bin_file( "unit_grad_iteration",
1221  data.cycle_data_p.cycle,
1222  data.iteration_data_p.iteration + 1,
1223  num_of_p_matrix_elements,
1224  1,
1225  "double_00.bin" ),
1226  num_of_p_matrix_elements,
1227  1,
1229 
1230  CHECK(
1231  compare_to_bin_file< double >( std::vector< double >( 1, data.iteration_data_p.t ),
1232  scene_dir,
1233  bin_file( "t_iteration",
1234  data.cycle_data_p.cycle,
1235  data.iteration_data_p.iteration + 1,
1236  1,
1237  1,
1238  "double_00.bin" ),
1239  1,
1240  1,
1242 
1243  CHECK( compare_to_bin_file< double >(
1244  std::vector< double >( 1, data.iteration_data_p.back_tracking_line_search_iters ),
1245  scene_dir,
1246  bin_file( "back_tracking_line_iter_count_iteration",
1247  data.cycle_data_p.cycle,
1248  data.iteration_data_p.iteration + 1,
1249  1,
1250  1,
1251  "double_00.bin" ),
1252  1,
1253  1,
1255 
1256  CHECK( compare_to_bin_file< double >(
1257  std::vector< double >(
1258  std::begin( data.iteration_data_p.next_params.curr_p_mat.vals ),
1259  std::end( data.iteration_data_p.next_params.curr_p_mat.vals ) ),
1260  scene_dir,
1261  bin_file( "next_p_matrix_iteration",
1262  data.cycle_data_p.cycle,
1263  data.iteration_data_p.iteration + 1,
1264  num_of_p_matrix_elements,
1265  1,
1266  "double_00.bin" ),
1267  num_of_p_matrix_elements,
1268  1,
1270 
1271  CHECK( compare_to_bin_file< double >(
1272  std::vector< double >( 1, data.iteration_data_p.next_params.cost ),
1273  scene_dir,
1274  bin_file( "next_cost_iteration",
1275  data.cycle_data_p.cycle,
1276  data.iteration_data_p.iteration + 1,
1277  1,
1278  1,
1279  "double_00.bin" ),
1280  1,
1281  1,
1283  }
1284  };
1285 
1286  // Our code doesn't count the first iteration; the Matlab code starts at 1 even if it doesn't do
1287  // anything...
1288  // REQUIRE( cal.optimize( cb ) + 1 == md.n_iterations );
1289  profiler.section( "Optimizing" );
1290  auto n_cycles = cal.optimize( cb );
1291  profiler.section_end();
1292 
1293 
1294  auto new_calibration = cal.get_calibration();
1295  auto cost = cal.get_cost();
1296 
1297  auto filename = bin_file( "new_calib", num_of_calib_elements, 1, "double_00" ) + ".bin";
1298  TRACE( "Comparing " << filename << " ..." );
1299  algo::calib matlab_calib;
1300  double matlab_cost = 0;
1301  CHECK( get_calib_and_cost_from_raw_data( matlab_calib, matlab_cost, scene_dir, filename ) );
1302  CHECK( compare_calib( new_calibration, cost, matlab_calib, matlab_cost ) );
1303  new_calibration.copy_coefs( matlab_calib );
1304  if( stats )
1305  {
1306  stats->cost = cost;
1307  stats->d_cost = cost - matlab_cost;
1308  }
1309 
1310 
1311 #if 1
1312  auto vertices = read_vector_from< algo::double3 >(
1313  bin_file( join( bin_dir( scene_dir ), "end_vertices" ), 3, md.n_edges, "double_00.bin" ) );
1314 
1315  if( stats )
1316  {
1317  auto our_uvmap = algo::get_texture_map( depth_data.vertices,
1318  new_calibration,
1319  new_calibration.calc_p_mat() );
1320  auto matlab_uvmap
1321  = algo::get_texture_map( vertices, matlab_calib, matlab_calib.calc_p_mat() );
1322 
1323  CHECK( our_uvmap.size() == matlab_uvmap.size() );
1324  if( our_uvmap.size() == matlab_uvmap.size() )
1325  stats->d_movement = cal.calc_correction_in_pixels( our_uvmap, matlab_uvmap );
1326  else
1327  stats->d_movement = -1;
1328  }
1329 
1330 
1331  algo::p_matrix p_mat;
1332 
1333  auto p_vec = read_vector_from< double >( bin_file( join( bin_dir( scene_dir ), "end_p_matrix" ),
1334  num_of_p_matrix_elements,
1335  1,
1336  "double_00.bin" ) );
1337 
1338  std::copy( p_vec.begin(), p_vec.end(), p_mat.vals );
1339 
1340  algo::p_matrix p_mat_opt;
1341 
1342  auto p_vec_opt
1343  = read_vector_from< double >( bin_file( join( bin_dir( scene_dir ), "end_p_matrix_opt" ),
1344  num_of_p_matrix_elements,
1345  1,
1346  "double_00.bin" ) );
1347 
1348  std::copy( p_vec_opt.begin(), p_vec_opt.end(), p_mat_opt.vals );
1349 
1350  cal.set_final_data( vertices, p_mat, p_mat_opt );
1351 
1352  //--
1353 
1354  // Pixel movement is OK, but some sections have negative cost
1355  profiler.section( "Checking output validity" );
1356  bool const is_valid_results = cal.is_valid_results();
1357  profiler.section_end();
1358  bool const matlab_valid_results = md.is_output_valid;
1359  CHECK( is_valid_results == matlab_valid_results );
1360  if( stats )
1361  {
1362  stats->n_cycles = n_cycles;
1363  stats->n_valid_result = is_valid_results;
1364  stats->n_valid_result_diff = is_valid_results != matlab_valid_results;
1365 
1366  stats->n_converged = is_valid_results && is_scene_valid;
1367  bool const matlab_converged = matlab_valid_results && matlab_scene_valid;
1368  stats->n_converged_diff = bool( stats->n_converged ) != matlab_converged;
1369  }
1370 
1371  double const movement_in_pixels = cal.calc_correction_in_pixels( new_calibration );
1372  double const matlab_movement_in_pixels = md.correction_in_pixels;
1373  CHECK( movement_in_pixels == approx( matlab_movement_in_pixels ) );
1374  if( stats )
1375  {
1376  stats->movement = movement_in_pixels;
1377  // stats->d_movement = movement_in_pixels - matlab_movement_in_pixels;
1378  }
1379 
1380  CHECK( compare_to_bin_file< double >( z_data.cost_diff_per_section,
1381  scene_dir,
1382  "costDiffPerSection",
1383  4,
1384  1,
1385  "double_00",
1387 
1388  // svm - remove xyMovementFromOrigin because its still not implemented
1389  auto svm_features_mat = read_vector_from< double >(
1390  bin_file( join( bin_dir( scene_dir ), "svm_featuresMat" ), 10, 1, "double_00.bin" ) );
1391 
1392  svm_features_mat.erase( svm_features_mat.begin() + 7 );
1393  auto svm_mat = svm_features;
1394  svm_mat.erase( svm_mat.begin() + 7 );
1395 
1396  CHECK( compare_same_vectors( svm_features_mat, svm_mat ) );
1397 
1398  // CHECK(compare_to_bin_file< double >(svm_features, scene_dir, "svm_featuresMat", 10, 1,
1399  // "double_00", compare_same_vectors));
1400  CHECK( compare_to_bin_file< double >( decision_params.distribution_per_section_depth,
1401  scene_dir,
1402  "svm_edgeWeightDistributionPerSectionDepth",
1403  1,
1404  4,
1405  "double_00",
1407  CHECK( compare_to_bin_file< double >( decision_params.distribution_per_section_rgb,
1408  scene_dir,
1409  "svm_edgeWeightDistributionPerSectionRgb",
1410  1,
1411  4,
1412  "double_00",
1414  CHECK( compare_to_bin_file< double >( decision_params.edge_weights_per_dir,
1415  scene_dir,
1416  "svm_edgeWeightsPerDir",
1417  4,
1418  1,
1419  "double_00",
1421  CHECK( compare_to_bin_file< double >( decision_params.improvement_per_section,
1422  scene_dir,
1423  "svm_improvementPerSection",
1424  4,
1425  1,
1426  "double_00",
1428 #endif
1429 
1430  profiler.stop();
1431 
1432  if( stats )
1433  stats->memory_consumption_peak = profiler.get_peak() - profiler.get_baseline();
1434 }
size_t n_converged_diff
Definition: compare-scene.h:8
GLuint GLuint end
size_t n_converged
Definition: compare-scene.h:8
Approx approx(F f)
Definition: approx.h:106
librealsense::algo::depth_to_rgb_calibration::algo_calibration_registers algo_calibration_registers
Definition: scene-data.h:274
float memory_consumption_peak
Definition: compare-scene.h:12
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 is_output_valid
Definition: scene-data.h:175
bool get_calib_and_cost_from_raw_data(algo::calib &calib, double &cost, std::string const &scene_dir, std::string const &filename)
std::string bin_file(std::string const &prefix, size_t cycle, size_t iteration, size_t w, size_t h, std::string const &suffix)
Definition: scene-data.h:19
std::string join(const std::string &base, const std::string &path)
Definition: filesystem.h:113
uint64_t n_valid_pixels
Definition: scene-data.h:171
void section_end()
Definition: profiler.h:56
librealsense::algo::depth_to_rgb_calibration::algo_calibration_info cal_info
Definition: scene-data.h:219
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:10806
void set_final_data(const std::vector< double3 > &vertices, const p_matrix &p_mat, const p_matrix &p_mat_opt=p_matrix())
Definition: optimizer.cpp:1828
float get_peak() const
Definition: profiler.h:88
double d_cost
Definition: compare-scene.h:9
uint64_t n_relevant_pixels
Definition: scene-data.h:172
GLsizei const GLchar *const * string
std::string rgb_prev_file
Definition: scene-data.h:177
bool read_thermal_data(std::string dir, double hum_temp, double &scale)
e
Definition: rmse.py:177
bool compare_calib(algo::calib const &calib, double cost, algo::calib calib_from_file, double cost_matlab)
std::string z_file
Definition: scene-data.h:180
librealsense::algo::depth_to_rgb_calibration::algo_calibration_registers cal_regs
Definition: scene-data.h:220
double movement
Definition: compare-scene.h:10
size_t optimize(std::function< void(data_collect const &data) > iteration_callback=nullptr)
Definition: optimizer.cpp:1977
size_t n_valid_scene_diff
Definition: compare-scene.h:6
librealsense::algo::depth_to_rgb_calibration::rs2_intrinsics_double z
Definition: scene-data.h:217
not_this_one begin(...)
bool compare_same_vectors(std::vector< F > const &matlab, std::vector< D > const &cpp)
std::ostream & cout()
float get_baseline() const
Definition: profiler.h:89
size_t n_valid_scene
Definition: compare-scene.h:6
#define WARN(msg)
Definition: catch.hpp:17431
std::string rgb_file
Definition: scene-data.h:176
std::string ir_file
Definition: scene-data.h:179
size_t n_valid_result_diff
Definition: compare-scene.h:7
std::string rgb_prev_valid_file
Definition: scene-data.h:178
uint64_t n_edges
Definition: scene-data.h:170
uint64_t n_valid_ir_edges
Definition: scene-data.h:173
decision_params const & get_decision_params() const
Definition: optimizer.h:350
std::vector< double > const & get_extracted_features() const
Definition: optimizer.h:351
rs2_dsm_params params
Definition: scene-data.h:273
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)
Definition: d2rgb-common.h:31
size_t n_cycles
Definition: compare-scene.h:11
double d_movement
Definition: compare-scene.h:10
camera_params read_camera_params(std::string const &scene_dir, std::string const &filename)
Definition: scene-data.h:225
void compare_preprocessing_data(std::string const &scene_dir, algo::z_frame_data const &depth_data, algo::ir_frame_data const &ir_data, algo::yuy2_frame_data const &yuy_data, scene_metadata const &md)
Definition: compare-scene.h:93
yuy2_frame_data const & get_yuy_data() const
Definition: optimizer.h:348
double calc_correction_in_pixels(std::vector< double2 > const &old_uvmap, std::vector< double2 > const &new_uvmap) const
size_t n_valid_result
Definition: compare-scene.h:7
rs2_dsm_params dsm_params
Definition: scene-data.h:218
bool is_scene_valid(input_validity_data *data=nullptr)
static const struct @18 vertices[3]
void section(char const *heading)
Definition: profiler.h:49
bool is_scene_valid
Definition: scene-data.h:174
uvmap_t get_texture_map(std::vector< double3 > const &points, const calib &cal, const p_matrix &p_mat)
Definition: uvmap.cpp:52
librealsense::algo::depth_to_rgb_calibration::rs2_intrinsics_double rgb
Definition: scene-data.h:216
void compare_vertices_to_los_data(std::string const &scene_dir, size_t num_of_vertices, size_t cycle, std::string const &time, algo::convert_norm_vertices_to_los_data const &data)
Definition: compare-scene.h:15
struct librealsense::algo::depth_to_rgb_calibration::yuy2_frame_data::@0 debug
void compare_scene(std::string const &scene_dir, bool debug_mode=true, scene_stats *stats=nullptr)
std::string bin_dir(std::string const &scene_dir)
Definition: scene-data.h:13
dsm_params read_dsm_params(std::string const &scene_dir, std::string const &filename)
Definition: scene-data.h:278
GLboolean * data
void stop()
Definition: profiler.h:79
double correction_in_pixels
Definition: scene-data.h:169
double cost
Definition: compare-scene.h:9
#define CHECK(condition)
Definition: parser.hpp:150
librealsense::algo::depth_to_rgb_calibration::algo_calibration_info regs
Definition: scene-data.h:275
void copy(void *dst, void const *src, size_t size)
Definition: types.cpp:836
void read_data_from(std::string const &filename, T *data)
Definition: scene-data.h:37


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