@@ -122,7 +122,7 @@ def run(self):
122122 # update progress
123123 self .signals .progressed .emit (self .start + iter )
124124 self .signals .messaged .emit (f'Pre-processing image { i } /{ nb_im } ' )
125- cv_rgb_img = cv2 . imread (rgb_path )
125+ cv_rgb_img = cv_read_all_path (rgb_path )
126126
127127 und = undis (cv_rgb_img , rgb_xml_path )
128128 crop = match_rgb (und , self .drone_model )
@@ -135,7 +135,8 @@ def run(self):
135135 new_name = file [:- 4 ] + 'crop.JPG'
136136
137137 dest_path = os .path .join (self .dest_crop_folder , new_name )
138- cv2 .imwrite (dest_path , crop )
138+
139+ cv_write_all_path (crop , dest_path )
139140
140141 self .signals .finished .emit ()
141142
@@ -200,6 +201,17 @@ def get_resolution(img_path):
200201
201202
202203# LENS RELATED METHODS (GENERAL)
204+ def cv_read_all_path (path ):
205+ """
206+ Allows reading image from any kind of unicode character (useful for french accents, for example)
207+ """
208+ img = cv2 .imdecode (np .fromfile (path , dtype = np .uint8 ), cv2 .IMREAD_UNCHANGED )
209+ return img
210+
211+ def cv_write_all_path (img , path ):
212+ is_success , im_buf_arr = cv2 .imencode (".JPG" , img )
213+ im_buf_arr .tofile (path )
214+
203215def undis (cv_img , xml_path ):
204216 def read_matrices (xml_path ):
205217 cv_file = cv2 .FileStorage (xml_path , cv2 .FILE_STORAGE_READ )
@@ -405,12 +417,13 @@ def create_undis_folder(list_ir_paths, drone_model, dest_und_folder):
405417 ir_xml_path = m3t_ir_xml_path
406418
407419 for ir_path in list_ir_paths :
408- cv_ir_img = cv2 . imread (ir_path )
420+ cv_ir_img = cv_read_all_path (ir_path )
409421 cv_und = undis (cv_ir_img , ir_xml_path )
410422 _ , file = os .path .split (ir_path )
411423 new_name = file [:- 4 ] + 'undis.JPG'
412424 dest_path = os .path .join (dest_und_folder , new_name )
413- cv2 .imwrite (dest_path , cv_und )
425+ cv_write_all_path (cv_und , dest_path )
426+
414427
415428
416429def create_rgb_crop_folder (list_rgb_paths , drone_model , scale_percent , dest_crop_folder , progressbar , start , stop ):
@@ -419,7 +432,7 @@ def create_rgb_crop_folder(list_rgb_paths, drone_model, scale_percent, dest_crop
419432 for i , rgb_path in enumerate (list_rgb_paths ):
420433 iter = i * (stop - start ) / nb_im
421434 progressbar .setProperty ("value" , start + iter )
422- cv_rgb_img = cv2 . imread (rgb_path )
435+ cv_rgb_img = cv_read_all_path (rgb_path )
423436
424437 if drone_model == 'MAVIC2-ENTERPRISE-ADVANCED' :
425438 rgb_xml_path = m2t_rgb_xml_path
@@ -611,7 +624,7 @@ def process_one_th_picture(param, drone_model, ir_img_path, dest_path, tmin, tma
611624 img_th_smooth .save (dest_path )
612625 elif post_process == 'edge (from rgb)' :
613626 img_thermal .save (dest_path )
614- cv_ir_img = cv2 . imread (dest_path )
627+ cv_ir_img = cv_read_all_path (dest_path )
615628
616629 if drone_model == 'MAVIC2-ENTERPRISE-ADVANCED' :
617630 ir_xml_path = m2t_ir_xml_path
@@ -621,7 +634,7 @@ def process_one_th_picture(param, drone_model, ir_img_path, dest_path, tmin, tma
621634 rgb_xml_path = m3t_rgb_xml_path
622635
623636 cv_ir_img = undis (cv_ir_img , ir_xml_path )
624- cv_match_rgb_img = cv2 . imread (rgb_path )
637+ cv_match_rgb_img = cv_read_all_path (rgb_path )
625638 add_lines_from_rgb (cv_ir_img , cv_match_rgb_img , drone_model , dest_path )
626639
627640 # elif post_process == 'superpixel':
0 commit comments