|
27 | 27 | colmap_command = '"{}"'.format(args.colmap_executable) if len(args.colmap_executable) > 0 else "colmap"
|
28 | 28 | magick_command = '"{}"'.format(args.magick_executable) if len(args.magick_executable) > 0 else "magick"
|
29 | 29 | use_gpu = 1 if not args.no_gpu else 0
|
| 30 | +clamp_exit_code = lambda code: code if code <= 255 else 1 |
30 | 31 |
|
31 | 32 | if not args.skip_matching:
|
32 | 33 | os.makedirs(args.source_path + "/distorted/sparse", exist_ok=True)
|
|
41 | 42 | exit_code = os.system(feat_extracton_cmd)
|
42 | 43 | if exit_code != 0:
|
43 | 44 | logging.error(f"Feature extraction failed with code {exit_code}. Exiting.")
|
44 |
| - exit(exit_code) |
| 45 | + exit(clamp_exit_code(exit_code)) |
45 | 46 |
|
46 | 47 | ## Feature matching
|
47 | 48 | feat_matching_cmd = colmap_command + " exhaustive_matcher \
|
|
50 | 51 | exit_code = os.system(feat_matching_cmd)
|
51 | 52 | if exit_code != 0:
|
52 | 53 | logging.error(f"Feature matching failed with code {exit_code}. Exiting.")
|
53 |
| - exit(exit_code) |
| 54 | + exit(clamp_exit_code(exit_code)) |
54 | 55 |
|
55 | 56 | ### Bundle adjustment
|
56 | 57 | # The default Mapper tolerance is unnecessarily large,
|
|
63 | 64 | exit_code = os.system(mapper_cmd)
|
64 | 65 | if exit_code != 0:
|
65 | 66 | logging.error(f"Mapper failed with code {exit_code}. Exiting.")
|
66 |
| - exit(exit_code) |
| 67 | + exit(clamp_exit_code(exit_code)) |
67 | 68 |
|
68 | 69 | ### Image undistortion
|
69 | 70 | ## We need to undistort our images into ideal pinhole intrinsics.
|
|
75 | 76 | exit_code = os.system(img_undist_cmd)
|
76 | 77 | if exit_code != 0:
|
77 | 78 | logging.error(f"Mapper failed with code {exit_code}. Exiting.")
|
78 |
| - exit(exit_code) |
| 79 | + exit(clamp_exit_code(exit_code)) |
79 | 80 |
|
80 | 81 | files = os.listdir(args.source_path + "/sparse")
|
81 | 82 | os.makedirs(args.source_path + "/sparse/0", exist_ok=True)
|
|
105 | 106 | exit_code = os.system(magick_command + " mogrify -resize 50% " + destination_file)
|
106 | 107 | if exit_code != 0:
|
107 | 108 | logging.error(f"50% resize failed with code {exit_code}. Exiting.")
|
108 |
| - exit(exit_code) |
| 109 | + exit(clamp_exit_code(exit_code)) |
109 | 110 |
|
110 | 111 | destination_file = os.path.join(args.source_path, "images_4", file)
|
111 | 112 | shutil.copy2(source_file, destination_file)
|
112 | 113 | exit_code = os.system(magick_command + " mogrify -resize 25% " + destination_file)
|
113 | 114 | if exit_code != 0:
|
114 | 115 | logging.error(f"25% resize failed with code {exit_code}. Exiting.")
|
115 |
| - exit(exit_code) |
| 116 | + exit(clamp_exit_code(exit_code)) |
116 | 117 |
|
117 | 118 | destination_file = os.path.join(args.source_path, "images_8", file)
|
118 | 119 | shutil.copy2(source_file, destination_file)
|
119 | 120 | exit_code = os.system(magick_command + " mogrify -resize 12.5% " + destination_file)
|
120 | 121 | if exit_code != 0:
|
121 | 122 | logging.error(f"12.5% resize failed with code {exit_code}. Exiting.")
|
122 |
| - exit(exit_code) |
| 123 | + exit(clamp_exit_code(exit_code)) |
123 | 124 |
|
124 | 125 | print("Done.")
|
0 commit comments