MCPcopy Create free account
hub / github.com/OpenImagingLab/4DSloMo / read_intrinsics_binary

Function read_intrinsics_binary

scene/colmap_loader.py:203–229  ·  view source on GitHub ↗

see: src/base/reconstruction.cc void Reconstruction::WriteCamerasBinary(const std::string& path) void Reconstruction::ReadCamerasBinary(const std::string& path)

(path_to_model_file)

Source from the content-addressed store, hash-verified

201
202
203def 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
232def read_extrinsics_text(path):

Callers 1

readColmapSceneInfoFunction · 0.90

Calls 2

read_next_bytesFunction · 0.85
CameraClass · 0.85

Tested by

no test coverage detected