()
| 72 | |
| 73 | |
| 74 | def main(): |
| 75 | import sys |
| 76 | if len(sys.argv) != 3: |
| 77 | print("Usage: python read_model.py " |
| 78 | "path/to/model/folder/txt path/to/model/folder/bin") |
| 79 | return |
| 80 | |
| 81 | print("Comparing text and binary models ...") |
| 82 | |
| 83 | path_to_model_txt_folder = sys.argv[1] |
| 84 | path_to_model_bin_folder = sys.argv[2] |
| 85 | cameras_txt, images_txt, points3D_txt = \ |
| 86 | read_model(path_to_model_txt_folder, ext=".txt") |
| 87 | cameras_bin, images_bin, points3D_bin = \ |
| 88 | read_model(path_to_model_bin_folder, ext=".bin") |
| 89 | compare_cameras(cameras_txt, cameras_bin) |
| 90 | compare_images(images_txt, images_bin) |
| 91 | compare_points(points3D_txt, points3D_bin) |
| 92 | |
| 93 | print("... text and binary models are equal.") |
| 94 | print("Saving text model and reloading it ...") |
| 95 | |
| 96 | tmpdir = mkdtemp() |
| 97 | write_model(cameras_bin, images_bin, points3D_bin, tmpdir, ext='.txt') |
| 98 | cameras_txt, images_txt, points3D_txt = \ |
| 99 | read_model(tmpdir, ext=".txt") |
| 100 | compare_cameras(cameras_txt, cameras_bin) |
| 101 | compare_images(images_txt, images_bin) |
| 102 | compare_points(points3D_txt, points3D_bin) |
| 103 | |
| 104 | print("... saved text and loaded models are equal.") |
| 105 | print("Saving binary model and reloading it ...") |
| 106 | |
| 107 | write_model(cameras_bin, images_bin, points3D_bin, tmpdir, ext='.bin') |
| 108 | cameras_bin, images_bin, points3D_bin = \ |
| 109 | read_model(tmpdir, ext=".bin") |
| 110 | compare_cameras(cameras_txt, cameras_bin) |
| 111 | compare_images(images_txt, images_bin) |
| 112 | compare_points(points3D_txt, points3D_bin) |
| 113 | |
| 114 | print("... saved binary and loaded models are equal.") |
| 115 | |
| 116 | |
| 117 | if __name__ == "__main__": |
no test coverage detected