MCPcopy Create free account
hub / github.com/NVlabs/InstantSplat / read_intrinsics_binary

Function read_intrinsics_binary

scene/colmap_loader.py:219–245  ·  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

217
218
219def read_intrinsics_binary(path_to_model_file):
220 """
221 see: src/base/reconstruction.cc
222 void Reconstruction::WriteCamerasBinary(const std::string& path)
223 void Reconstruction::ReadCamerasBinary(const std::string& path)
224 """
225 cameras = {}
226 with open(path_to_model_file, "rb") as fid:
227 num_cameras = read_next_bytes(fid, 8, "Q")[0]
228 for _ in range(num_cameras):
229 camera_properties = read_next_bytes(
230 fid, num_bytes=24, format_char_sequence="iiQQ")
231 camera_id = camera_properties[0]
232 model_id = camera_properties[1]
233 model_name = CAMERA_MODEL_IDS[camera_properties[1]].model_name
234 width = camera_properties[2]
235 height = camera_properties[3]
236 num_params = CAMERA_MODEL_IDS[model_id].num_params
237 params = read_next_bytes(fid, num_bytes=8*num_params,
238 format_char_sequence="d"*num_params)
239 cameras[camera_id] = Camera(id=camera_id,
240 model=model_name,
241 width=width,
242 height=height,
243 params=np.array(params))
244 assert len(cameras) == num_cameras
245 return cameras
246
247
248def read_extrinsics_text(path):

Callers

nothing calls this directly

Calls 2

read_next_bytesFunction · 0.85
CameraClass · 0.85

Tested by

no test coverage detected