(path, ext="")
| 449 | |
| 450 | |
| 451 | def read_model(path, ext=""): |
| 452 | # try to detect the extension automatically |
| 453 | if ext == "": |
| 454 | if detect_model_format(path, ".bin"): |
| 455 | ext = ".bin" |
| 456 | elif detect_model_format(path, ".txt"): |
| 457 | ext = ".txt" |
| 458 | else: |
| 459 | print("Provide model format: '.bin' or '.txt'") |
| 460 | return |
| 461 | |
| 462 | if ext == ".txt": |
| 463 | cameras = read_cameras_text(os.path.join(path, "cameras" + ext)) |
| 464 | images = read_images_text(os.path.join(path, "images" + ext)) |
| 465 | points3D = read_points3D_text(os.path.join(path, "points3D") + ext) |
| 466 | else: |
| 467 | cameras = read_cameras_binary(os.path.join(path, "cameras" + ext)) |
| 468 | images = read_images_binary(os.path.join(path, "images" + ext)) |
| 469 | points3D = read_points3D_binary(os.path.join(path, "points3D") + ext) |
| 470 | return cameras, images, points3D |
| 471 | |
| 472 | |
| 473 | def write_model(cameras, images, points3D, path, ext=".bin"): |
no test coverage detected