MCPcopy Create free account
hub / github.com/ai4ce/RAP / read_points3D_binary

Function read_points3D_binary

utils/read_write_model.py:389–424  ·  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

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

Callers 1

read_modelFunction · 0.70

Calls 1

read_next_bytesFunction · 0.70

Tested by

no test coverage detected