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

Function read_points3D_binary

datasets_preprocess/read_write_model.py:388–423  ·  view source on GitHub ↗

see: src/colmap/scene/reconstruction.cc void Reconstruction::ReadPoints3DBinary(const std::string& path) void Reconstruction::WritePoints3DBinary(const std::string& path)

(path_to_model_file)

Source from the content-addressed store, hash-verified

386
387
388def read_points3D_binary(path_to_model_file):
389 """
390 see: src/colmap/scene/reconstruction.cc
391 void Reconstruction::ReadPoints3DBinary(const std::string& path)
392 void Reconstruction::WritePoints3DBinary(const std::string& path)
393 """
394 points3D = {}
395 with open(path_to_model_file, "rb") as fid:
396 num_points = read_next_bytes(fid, 8, "Q")[0]
397 for _ in range(num_points):
398 binary_point_line_properties = read_next_bytes(
399 fid, num_bytes=43, format_char_sequence="QdddBBBd"
400 )
401 point3D_id = binary_point_line_properties[0]
402 xyz = np.array(binary_point_line_properties[1:4])
403 rgb = np.array(binary_point_line_properties[4:7])
404 error = np.array(binary_point_line_properties[7])
405 track_length = read_next_bytes(fid, num_bytes=8, format_char_sequence="Q")[
406 0
407 ]
408 track_elems = read_next_bytes(
409 fid,
410 num_bytes=8 * track_length,
411 format_char_sequence="ii" * track_length,
412 )
413 image_ids = np.array(tuple(map(int, track_elems[0::2])))
414 point2D_idxs = np.array(tuple(map(int, track_elems[1::2])))
415 points3D[point3D_id] = Point3D(
416 id=point3D_id,
417 xyz=xyz,
418 rgb=rgb,
419 error=error,
420 image_ids=image_ids,
421 point2D_idxs=point2D_idxs,
422 )
423 return points3D
424
425
426def write_points3D_text(points3D, path):

Callers 1

read_modelFunction · 0.85

Calls 1

read_next_bytesFunction · 0.85

Tested by

no test coverage detected