@@ -60,6 +60,17 @@ fn image_to_option_feature_frame(
60
60
}
61
61
}
62
62
63
+ fn img_filter ( rp : glob:: GlobResult ) -> Option < std:: path:: PathBuf > {
64
+ if let Ok ( p) = rp {
65
+ for ext in & [ ".png" , ".jpg" ] {
66
+ if p. as_os_str ( ) . to_string_lossy ( ) . ends_with ( ext) {
67
+ return Some ( p) ;
68
+ }
69
+ }
70
+ }
71
+ None
72
+ }
73
+
63
74
pub fn load_euroc (
64
75
root_folder : & str ,
65
76
tag_detector : & TagDetector ,
@@ -72,18 +83,18 @@ pub fn load_euroc(
72
83
( 0 ..cam_num)
73
84
. map ( |cam_idx| {
74
85
log:: trace!( "loading cam{}" , cam_idx) ;
75
- let img_paths =
76
- glob ( format ! ( "{}/mav0/cam{}/data/*.png" , root_folder, cam_idx) . as_str ( ) )
77
- . expect ( "failed" ) ;
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 ( ) ) ) ;
86
+ let img_paths = glob ( format ! ( "{}/mav0/cam{}/data/*" , root_folder, cam_idx) . as_str ( ) )
87
+ . expect ( "failed" ) ;
88
+ let mut sorted_path: Vec < std:: path:: PathBuf > =
89
+ img_paths. into_iter ( ) . filter_map ( img_filter) . collect ( ) ;
90
+
91
+ sorted_path. sort_by ( |a, b| a. cmp ( b) ) ;
80
92
let new_paths: Vec < _ > = sorted_path. iter ( ) . skip ( start_idx) . step_by ( step) . collect ( ) ;
81
93
let mut time_frame: Vec < _ > = new_paths
82
94
. iter ( )
83
95
. par_bridge ( )
84
96
. progress_count ( new_paths. len ( ) as u64 )
85
97
. map ( |path| {
86
- let path = path. as_ref ( ) . unwrap ( ) ;
87
98
let time_ns = path_to_timestamp ( path) ;
88
99
let img = ImageReader :: open ( path) . unwrap ( ) . decode ( ) . unwrap ( ) ;
89
100
if let Some ( recording) = recording_option {
@@ -120,11 +131,13 @@ pub fn load_others(
120
131
) -> Vec < Vec < Option < FrameFeature > > > {
121
132
( 0 ..cam_num)
122
133
. map ( |cam_idx| {
123
- let img_paths = glob ( format ! ( "{}/**/cam{}/**/*.png" , root_folder , cam_idx ) . as_str ( ) )
124
- . expect ( "failed" ) ;
134
+ let img_paths =
135
+ glob ( format ! ( "{}/**/cam{}/**/*" , root_folder , cam_idx ) . as_str ( ) ) . expect ( "failed" ) ;
125
136
log:: trace!( "loading cam{}" , cam_idx) ;
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 ( ) ) ) ;
137
+ let mut sorted_path: Vec < std:: path:: PathBuf > =
138
+ img_paths. into_iter ( ) . filter_map ( img_filter) . collect ( ) ;
139
+
140
+ sorted_path. sort_by ( |a, b| a. cmp ( b) ) ;
128
141
let new_paths: Vec < _ > = sorted_path
129
142
. iter ( )
130
143
. skip ( start_idx)
@@ -136,7 +149,6 @@ pub fn load_others(
136
149
. par_bridge ( )
137
150
. progress_count ( new_paths. len ( ) as u64 )
138
151
. map ( |( idx, path) | {
139
- let path = path. as_ref ( ) . unwrap ( ) ;
140
152
let time_ns = * idx as i64 * 100000000 ;
141
153
let img = ImageReader :: open ( path) . unwrap ( ) . decode ( ) . unwrap ( ) ;
142
154
if let Some ( recording) = recording_option {
0 commit comments