diff --git a/stitching/scan.py b/stitching/scan.py index 891d78db91aabcca56e8393812b9d513f8db03a1..1a3245d5bba262df94448672772e80089d805c4b 100644 --- a/stitching/scan.py +++ b/stitching/scan.py @@ -55,7 +55,7 @@ def get_biggest_subset(img_names, imgs, features, matches, conf_thresh=1.0, matc num = len(indices) if num < 2: print('Need more images') - exit() + raise SystemExit for i in range(num): img_subset.append(imgs[indices[i, 0]]) img_names_subset.append(img_names[indices[i, 0]]) @@ -69,7 +69,7 @@ def estimate_cameras(features, matches): b, cameras = estimator.apply(features, matches, None) if not b: print('Homography estimation failed') - exit() + raise SystemExit for cam in cameras: cam.R = cam.R.astype(np.float32) return cameras @@ -93,7 +93,7 @@ def refine_cameras(features, matches, cameras, refine_mask): b, refined_cams = adjuster.apply(features, matches, cameras) if not b: print('Camera parameters adjusting failed') - exit() + raise SystemExit return refined_cams @@ -233,10 +233,13 @@ if __name__ == '__main__': # img_names = [f'pano_{i}.jpg' for i in range(1, 4)] # img_names = ['left.png', 'right.png'] # img_names = ['left2.png', 'right2.png'] - img_names = ['wien_low1.jpg', 'wien_low2.jpg'] + img_names = ['wien_low1.jpg', 'prague2.jpg'] # img_names = ['prague1.jpg', 'prague2.jpg'] imgs = [cv.imread(f'imgs/{name}') for name in img_names] - result = full_stitching_pipeline(imgs, img_names) - out_name = 'imgs_out/wien_low3.jpg' - cv.imwrite(out_name, result) - print('Stitched image saved as ' + out_name) + try: + result = full_stitching_pipeline(imgs, img_names) + out_name = 'imgs_out/wien_test.jpg' + cv.imwrite(out_name, result) + print('Stitched image saved as ' + out_name) + except SystemExit: + print('program execution stopped!')