3737magick_command = '"{}"' .format (args .magick_executable ) if len (args .magick_executable ) > 0 else "magick"
3838use_gpu = 1 if not args .no_gpu else 0
3939
40+ EXIT_FAIL = 1
41+
4042if not args .skip_matching :
4143 os .makedirs (args .source_path + "/distorted/sparse" , exist_ok = True )
4244
5052 exit_code = os .system (feat_extracton_cmd )
5153 if exit_code != 0 :
5254 logging .error (f"Feature extraction failed with code { exit_code } . Exiting." )
53- exit (exit_code )
55+ exit (EXIT_FAIL )
5456
5557 ## Feature matching
5658 feat_matching_cmd = colmap_command + " exhaustive_matcher \
5961 exit_code = os .system (feat_matching_cmd )
6062 if exit_code != 0 :
6163 logging .error (f"Feature matching failed with code { exit_code } . Exiting." )
62- exit (exit_code )
64+ exit (EXIT_FAIL )
6365
6466 ### Bundle adjustment
6567 # The default Mapper tolerance is unnecessarily large,
7274 exit_code = os .system (mapper_cmd )
7375 if exit_code != 0 :
7476 logging .error (f"Mapper failed with code { exit_code } . Exiting." )
75- exit (exit_code )
77+ exit (EXIT_FAIL )
7678
7779
7880# select the largest submodel
109111exit_code = os .system (img_undist_cmd )
110112if exit_code != 0 :
111113 logging .error (f"image_undistorter failed with code { exit_code } . Exiting." )
112- exit (exit_code )
114+ exit (EXIT_FAIL )
113115
114116
115117def remove_dir_if_exist (path ):
@@ -129,7 +131,7 @@ def remove_dir_if_exist(path):
129131 exit_code = os .system (model_converter_cmd )
130132 if exit_code != 0 :
131133 logging .error (f"model_converter failed with code { exit_code } . Exiting." )
132- exit (exit_code )
134+ exit (EXIT_FAIL )
133135
134136 # replace '.jpg' to '.png'
135137 with open (args .source_path + "/alpha_distorted_sparse_txt/images.txt" , "r+" ) as f :
@@ -148,7 +150,7 @@ def remove_dir_if_exist(path):
148150 exit_code = os .system (seg_undist_cmd )
149151 if exit_code != 0 :
150152 logging .error (f"image_undistorter for segs failed with code { exit_code } . Exiting." )
151- exit (exit_code )
153+ exit (EXIT_FAIL )
152154
153155 # switch images
154156 remove_dir_if_exist (f'{ args .source_path } /alpha_undistorted_sparse/alphas' )
@@ -215,20 +217,20 @@ def concat_alpha(seg_path):
215217 exit_code = os .system ("mogrify -resize 50% " + destination_file )
216218 if exit_code != 0 :
217219 logging .error (f"50% resize failed with code { exit_code } . Exiting." )
218- exit (exit_code )
220+ exit (EXIT_FAIL )
219221
220222 destination_file = os .path .join (args .source_path , "images_4" , file )
221223 shutil .copy2 (source_file , destination_file )
222224 exit_code = os .system ("mogrify -resize 25% " + destination_file )
223225 if exit_code != 0 :
224226 logging .error (f"25% resize failed with code { exit_code } . Exiting." )
225- exit (exit_code )
227+ exit (EXIT_FAIL )
226228
227229 destination_file = os .path .join (args .source_path , "images_8" , file )
228230 shutil .copy2 (source_file , destination_file )
229231 exit_code = os .system ("mogrify -resize 12.5% " + destination_file )
230232 if exit_code != 0 :
231233 logging .error (f"12.5% resize failed with code { exit_code } . Exiting." )
232- exit (exit_code )
234+ exit (EXIT_FAIL )
233235
234236print ("Done." )
0 commit comments