see: src/base/reconstruction.cc void Reconstruction::WriteCamerasBinary(const std::string& path) void Reconstruction::ReadCamerasBinary(const std::string& path)
(path_to_model_file)
| 157 | |
| 158 | |
| 159 | def read_cameras_binary(path_to_model_file): |
| 160 | """ |
| 161 | see: src/base/reconstruction.cc |
| 162 | void Reconstruction::WriteCamerasBinary(const std::string& path) |
| 163 | void Reconstruction::ReadCamerasBinary(const std::string& path) |
| 164 | """ |
| 165 | cameras = {} |
| 166 | with open(path_to_model_file, "rb") as fid: |
| 167 | num_cameras = read_next_bytes(fid, 8, "Q")[0] |
| 168 | for camera_line_index in range(num_cameras): |
| 169 | camera_properties = read_next_bytes( |
| 170 | fid, num_bytes=24, format_char_sequence="iiQQ") |
| 171 | camera_id = camera_properties[0] |
| 172 | model_id = camera_properties[1] |
| 173 | model_name = CAMERA_MODEL_IDS[camera_properties[1]].model_name |
| 174 | width = camera_properties[2] |
| 175 | height = camera_properties[3] |
| 176 | num_params = CAMERA_MODEL_IDS[model_id].num_params |
| 177 | params = read_next_bytes(fid, num_bytes=8 * num_params, |
| 178 | format_char_sequence="d" * num_params) |
| 179 | cameras[camera_id] = Camera(id=camera_id, |
| 180 | model=model_name, |
| 181 | width=width, |
| 182 | height=height, |
| 183 | params=np.array(params)) |
| 184 | assert len(cameras) == num_cameras |
| 185 | return cameras |
| 186 | |
| 187 | |
| 188 | def write_cameras_text(cameras, path): |
no test coverage detected