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