MCPcopy
hub / github.com/cvg/Hierarchical-Localization / write_images_binary

Function write_images_binary

hloc/utils/read_write_model.py:290–308  ·  view source on GitHub ↗

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

(images, path_to_model_file)

Source from the content-addressed store, hash-verified

288
289
290def write_images_binary(images, path_to_model_file):
291 """
292 see: src/base/reconstruction.cc
293 void Reconstruction::ReadImagesBinary(const std::string& path)
294 void Reconstruction::WriteImagesBinary(const std::string& path)
295 """
296 with open(path_to_model_file, "wb") as fid:
297 write_next_bytes(fid, len(images), "Q")
298 for _, img in images.items():
299 write_next_bytes(fid, img.id, "i")
300 write_next_bytes(fid, img.qvec.tolist(), "dddd")
301 write_next_bytes(fid, img.tvec.tolist(), "ddd")
302 write_next_bytes(fid, img.camera_id, "i")
303 for char in img.name:
304 write_next_bytes(fid, char.encode("utf-8"), "c")
305 write_next_bytes(fid, b"\x00", "c")
306 write_next_bytes(fid, len(img.point3D_ids), "Q")
307 for xy, p3d_id in zip(img.xys, img.point3D_ids):
308 write_next_bytes(fid, [*xy, p3d_id], "ddq")
309
310
311def read_points3D_text(path):

Callers 1

write_modelFunction · 0.85

Calls 1

write_next_bytesFunction · 0.85

Tested by

no test coverage detected