see: src/base/reconstruction.cc void Reconstruction::WriteCamerasBinary(const std::string& path) void Reconstruction::ReadCamerasBinary(const std::string& path)
(path_to_model_file)
| 201 | |
| 202 | |
| 203 | def read_intrinsics_binary(path_to_model_file): |
| 204 | """ |
| 205 | see: src/base/reconstruction.cc |
| 206 | void Reconstruction::WriteCamerasBinary(const std::string& path) |
| 207 | void Reconstruction::ReadCamerasBinary(const std::string& path) |
| 208 | """ |
| 209 | cameras = {} |
| 210 | with open(path_to_model_file, "rb") as fid: |
| 211 | num_cameras = read_next_bytes(fid, 8, "Q")[0] |
| 212 | for _ in range(num_cameras): |
| 213 | camera_properties = read_next_bytes( |
| 214 | fid, num_bytes=24, format_char_sequence="iiQQ") |
| 215 | camera_id = camera_properties[0] |
| 216 | model_id = camera_properties[1] |
| 217 | model_name = CAMERA_MODEL_IDS[camera_properties[1]].model_name |
| 218 | width = camera_properties[2] |
| 219 | height = camera_properties[3] |
| 220 | num_params = CAMERA_MODEL_IDS[model_id].num_params |
| 221 | params = read_next_bytes(fid, num_bytes=8*num_params, |
| 222 | format_char_sequence="d"*num_params) |
| 223 | cameras[camera_id] = Camera(id=camera_id, |
| 224 | model=model_name, |
| 225 | width=width, |
| 226 | height=height, |
| 227 | params=np.array(params)) |
| 228 | assert len(cameras) == num_cameras |
| 229 | return cameras |
| 230 | |
| 231 | |
| 232 | def read_extrinsics_text(path): |
no test coverage detected