see: src/base/reconstruction.cc void Reconstruction::WriteCamerasBinary(const std::string& path) void Reconstruction::ReadCamerasBinary(const std::string& path)
(path_to_model_file)
| 125 | |
| 126 | |
| 127 | def read_cameras_binary(path_to_model_file): |
| 128 | """ |
| 129 | see: src/base/reconstruction.cc |
| 130 | void Reconstruction::WriteCamerasBinary(const std::string& path) |
| 131 | void Reconstruction::ReadCamerasBinary(const std::string& path) |
| 132 | """ |
| 133 | cameras = {} |
| 134 | with open(path_to_model_file, "rb") as fid: |
| 135 | num_cameras = read_next_bytes(fid, 8, "Q")[0] |
| 136 | for _ in range(num_cameras): |
| 137 | camera_properties = read_next_bytes( |
| 138 | fid, num_bytes=24, format_char_sequence="iiQQ") |
| 139 | camera_id = camera_properties[0] |
| 140 | model_id = camera_properties[1] |
| 141 | model_name = CAMERA_MODEL_IDS[camera_properties[1]].model_name |
| 142 | width = camera_properties[2] |
| 143 | height = camera_properties[3] |
| 144 | num_params = CAMERA_MODEL_IDS[model_id].num_params |
| 145 | params = read_next_bytes(fid, num_bytes=8*num_params, |
| 146 | format_char_sequence="d"*num_params) |
| 147 | cameras[camera_id] = Camera(id=camera_id, |
| 148 | model=model_name, |
| 149 | width=width, |
| 150 | height=height, |
| 151 | params=np.array(params)) |
| 152 | assert len(cameras) == num_cameras |
| 153 | return cameras |
| 154 | |
| 155 | |
| 156 | def write_cameras_text(cameras, path): |
no test coverage detected