Skip to content

Commit 9e62d65

Browse files
committed
return 1 always as a failure code
1 parent 7b72c54 commit 9e62d65

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

convert.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
magick_command = '"{}"'.format(args.magick_executable) if len(args.magick_executable) > 0 else "magick"
3737
use_gpu = 1 if not args.no_gpu else 0
3838

39+
EXIT_FAIL = 1
40+
3941
if not args.skip_matching:
4042
os.makedirs(args.source_path + "/distorted/sparse", exist_ok=True)
4143

@@ -49,7 +51,7 @@
4951
exit_code = os.system(feat_extracton_cmd)
5052
if exit_code != 0:
5153
logging.error(f"Feature extraction failed with code {exit_code}. Exiting.")
52-
exit(exit_code)
54+
exit(EXIT_FAIL)
5355

5456
## Feature matching
5557
feat_matching_cmd = colmap_command + " exhaustive_matcher \
@@ -58,7 +60,7 @@
5860
exit_code = os.system(feat_matching_cmd)
5961
if exit_code != 0:
6062
logging.error(f"Feature matching failed with code {exit_code}. Exiting.")
61-
exit(exit_code)
63+
exit(EXIT_FAIL)
6264

6365
### Bundle adjustment
6466
# The default Mapper tolerance is unnecessarily large,
@@ -71,7 +73,7 @@
7173
exit_code = os.system(mapper_cmd)
7274
if exit_code != 0:
7375
logging.error(f"Mapper failed with code {exit_code}. Exiting.")
74-
exit(exit_code)
76+
exit(EXIT_FAIL)
7577

7678
### Convert model to text format so we can read cameras
7779
convert_cmd = (colmap_command + " model_converter \
@@ -81,7 +83,7 @@
8183
exit_code = os.system(convert_cmd)
8284
if exit_code != 0:
8385
logging.error(f"Convert failed with code {exit_code}. Exiting.")
84-
exit(exit_code)
86+
exit(EXIT_FAIL)
8587

8688
### Image undistortion
8789
## We need to undistort our images into ideal pinhole intrinsics.
@@ -94,7 +96,7 @@
9496
exit_code = os.system(img_undist_cmd)
9597
if exit_code != 0:
9698
logging.error(f"image_undistorter failed with code {exit_code}. Exiting.")
97-
exit(exit_code)
99+
exit(EXIT_FAIL)
98100

99101

100102
def remove_dir_if_exist(path):
@@ -114,7 +116,7 @@ def remove_dir_if_exist(path):
114116
exit_code = os.system(model_converter_cmd)
115117
if exit_code != 0:
116118
logging.error(f"model_converter failed with code {exit_code}. Exiting.")
117-
exit(exit_code)
119+
exit(EXIT_FAIL)
118120

119121
# replace '.jpg' to '.png'
120122
with open(args.source_path + "/alpha_distorted_sparse_txt/images.txt", "r+") as f:
@@ -133,7 +135,7 @@ def remove_dir_if_exist(path):
133135
exit_code = os.system(seg_undist_cmd)
134136
if exit_code != 0:
135137
logging.error(f"image_undistorter for segs failed with code {exit_code}. Exiting.")
136-
exit(exit_code)
138+
exit(EXIT_FAIL)
137139

138140
# switch images
139141
remove_dir_if_exist(f'{args.source_path}/alpha_undistorted_sparse/alphas')
@@ -188,20 +190,20 @@ def concat_alpha(seg_path):
188190
exit_code = os.system("mogrify -resize 50% " + destination_file)
189191
if exit_code != 0:
190192
logging.error(f"50% resize failed with code {exit_code}. Exiting.")
191-
exit(exit_code)
193+
exit(EXIT_FAIL)
192194

193195
destination_file = os.path.join(args.source_path, "images_4", file)
194196
shutil.copy2(source_file, destination_file)
195197
exit_code = os.system("mogrify -resize 25% " + destination_file)
196198
if exit_code != 0:
197199
logging.error(f"25% resize failed with code {exit_code}. Exiting.")
198-
exit(exit_code)
200+
exit(EXIT_FAIL)
199201

200202
destination_file = os.path.join(args.source_path, "images_8", file)
201203
shutil.copy2(source_file, destination_file)
202204
exit_code = os.system("mogrify -resize 12.5% " + destination_file)
203205
if exit_code != 0:
204206
logging.error(f"12.5% resize failed with code {exit_code}. Exiting.")
205-
exit(exit_code)
207+
exit(EXIT_FAIL)
206208

207209
print("Done.")

0 commit comments

Comments
 (0)