@@ -8,6 +8,7 @@ use aprilgrid::detector::TagDetector;
88use glam:: Vec2 ;
99use glob:: glob;
1010use image:: { DynamicImage , ImageReader } ;
11+ use indicatif:: ParallelProgressIterator ;
1112use rayon:: prelude:: * ;
1213
1314const MIN_CORNERS : usize = 24 ;
@@ -74,14 +75,17 @@ pub fn load_euroc(
7475 let img_paths =
7576 glob ( format ! ( "{}/mav0/cam{}/data/*.png" , root_folder, cam_idx) . as_str ( ) )
7677 . expect ( "failed" ) ;
77- let mut time_frame: Vec < _ > = img_paths
78- . skip ( start_idx)
79- . step_by ( step)
78+ let mut sorted_path: Vec < _ > = img_paths. collect ( ) ;
79+ sorted_path. sort_by ( |a, b| a. as_ref ( ) . unwrap ( ) . cmp ( b. as_ref ( ) . unwrap ( ) ) ) ;
80+ let new_paths: Vec < _ > = sorted_path. iter ( ) . skip ( start_idx) . step_by ( step) . collect ( ) ;
81+ let mut time_frame: Vec < _ > = new_paths
82+ . iter ( )
8083 . par_bridge ( )
84+ . progress_count ( new_paths. len ( ) as u64 )
8185 . map ( |path| {
82- let path = path. unwrap ( ) ;
83- let time_ns = path_to_timestamp ( & path) ;
84- let img = ImageReader :: open ( & path) . unwrap ( ) . decode ( ) . unwrap ( ) ;
86+ let path = path. as_ref ( ) . unwrap ( ) ;
87+ let time_ns = path_to_timestamp ( path) ;
88+ let img = ImageReader :: open ( path) . unwrap ( ) . decode ( ) . unwrap ( ) ;
8589 if let Some ( recording) = recording_option {
8690 recording. set_time_nanos ( "stable" , time_ns) ;
8791 let topic = format ! ( "/cam{}" , cam_idx) ;
@@ -119,15 +123,22 @@ pub fn load_others(
119123 let img_paths = glob ( format ! ( "{}/**/cam{}/**/*.png" , root_folder, cam_idx) . as_str ( ) )
120124 . expect ( "failed" ) ;
121125 log:: trace!( "loading cam{}" , cam_idx) ;
122- let mut time_frame: Vec < _ > = img_paths
126+ let mut sorted_path: Vec < _ > = img_paths. collect ( ) ;
127+ sorted_path. sort_by ( |a, b| a. as_ref ( ) . unwrap ( ) . cmp ( b. as_ref ( ) . unwrap ( ) ) ) ;
128+ let new_paths: Vec < _ > = sorted_path
129+ . iter ( )
123130 . skip ( start_idx)
124131 . step_by ( step)
125132 . enumerate ( )
133+ . collect ( ) ;
134+ let mut time_frame: Vec < _ > = new_paths
135+ . iter ( )
126136 . par_bridge ( )
137+ . progress_count ( new_paths. len ( ) as u64 )
127138 . map ( |( idx, path) | {
128- let path = path. unwrap ( ) ;
129- let time_ns = idx as i64 * 100000000 ;
130- let img = ImageReader :: open ( & path) . unwrap ( ) . decode ( ) . unwrap ( ) ;
139+ let path = path. as_ref ( ) . unwrap ( ) ;
140+ let time_ns = * idx as i64 * 100000000 ;
141+ let img = ImageReader :: open ( path) . unwrap ( ) . decode ( ) . unwrap ( ) ;
131142 if let Some ( recording) = recording_option {
132143 recording. set_time_nanos ( "stable" , time_ns) ;
133144 let topic = format ! ( "/cam{}" , cam_idx) ;
0 commit comments