(path, ext="")
| 487 | |
| 488 | |
| 489 | def read_model(path, ext=""): |
| 490 | # try to detect the extension automatically |
| 491 | if ext == "": |
| 492 | if detect_model_format(path, ".bin"): |
| 493 | ext = ".bin" |
| 494 | elif detect_model_format(path, ".txt"): |
| 495 | ext = ".txt" |
| 496 | else: |
| 497 | print("Provide model format: '.bin' or '.txt'") |
| 498 | return |
| 499 | |
| 500 | if ext == ".txt": |
| 501 | cameras = read_cameras_text(os.path.join(path, "cameras" + ext)) |
| 502 | images = read_images_text(os.path.join(path, "images" + ext)) |
| 503 | points3D = read_points3D_text(os.path.join(path, "points3D") + ext) |
| 504 | else: |
| 505 | cameras = read_cameras_binary(os.path.join(path, "cameras" + ext)) |
| 506 | images = read_images_binary(os.path.join(path, "images" + ext)) |
| 507 | points3D = read_points3D_binary(os.path.join(path, "points3D") + ext) |
| 508 | return cameras, images, points3D |
| 509 | |
| 510 | |
| 511 | def write_model(cameras, images, points3D, path, ext=".bin"): |
no test coverage detected