MCPcopy Create free account
hub / github.com/TheMariday/marimapper / read_points3D_binary

Function read_points3D_binary

marimapper/pycolmap_tools/read_write_model.py:390–425  ·  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

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

Callers 2

binary_to_led_map_3dFunction · 0.90
read_modelFunction · 0.85

Calls 2

read_next_bytesFunction · 0.85
Point3DClass · 0.85

Tested by

no test coverage detected