MCPcopy Create free account
hub / github.com/CUT3R/CUT3R / write_images_binary

Function write_images_binary

datasets_preprocess/read_write_model.py:335–353  ·  view source on GitHub ↗

see: src/colmap/scene/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

333
334
335def write_images_binary(images, path_to_model_file):
336 """
337 see: src/colmap/scene/reconstruction.cc
338 void Reconstruction::ReadImagesBinary(const std::string& path)
339 void Reconstruction::WriteImagesBinary(const std::string& path)
340 """
341 with open(path_to_model_file, "wb") as fid:
342 write_next_bytes(fid, len(images), "Q")
343 for _, img in images.items():
344 write_next_bytes(fid, img.id, "i")
345 write_next_bytes(fid, img.qvec.tolist(), "dddd")
346 write_next_bytes(fid, img.tvec.tolist(), "ddd")
347 write_next_bytes(fid, img.camera_id, "i")
348 for char in img.name:
349 write_next_bytes(fid, char.encode("utf-8"), "c")
350 write_next_bytes(fid, b"\x00", "c")
351 write_next_bytes(fid, len(img.point3D_ids), "Q")
352 for xy, p3d_id in zip(img.xys, img.point3D_ids):
353 write_next_bytes(fid, [*xy, p3d_id], "ddq")
354
355
356def read_points3D_text(path):

Callers 1

write_modelFunction · 0.85

Calls 1

write_next_bytesFunction · 0.85

Tested by

no test coverage detected