MCPcopy Create free account
hub / github.com/XiaoBaiiiiii/colmap-pcd / read_points3D_binary

Function read_points3D_binary

scripts/python/read_write_model.py:335–362  ·  view source on GitHub ↗

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

333
334
335def read_points3D_binary(path_to_model_file):
336 """
337 see: src/base/reconstruction.cc
338 void Reconstruction::ReadPoints3DBinary(const std::string& path)
339 void Reconstruction::WritePoints3DBinary(const std::string& path)
340 """
341 points3D = {}
342 with open(path_to_model_file, "rb") as fid:
343 num_points = read_next_bytes(fid, 8, "Q")[0]
344 for _ in range(num_points):
345 binary_point_line_properties = read_next_bytes(
346 fid, num_bytes=43, format_char_sequence="QdddBBBd")
347 point3D_id = binary_point_line_properties[0]
348 xyz = np.array(binary_point_line_properties[1:4])
349 rgb = np.array(binary_point_line_properties[4:7])
350 error = np.array(binary_point_line_properties[7])
351 track_length = read_next_bytes(
352 fid, num_bytes=8, format_char_sequence="Q")[0]
353 track_elems = read_next_bytes(
354 fid, num_bytes=8*track_length,
355 format_char_sequence="ii"*track_length)
356 image_ids = np.array(tuple(map(int, track_elems[0::2])))
357 point2D_idxs = np.array(tuple(map(int, track_elems[1::2])))
358 points3D[point3D_id] = Point3D(
359 id=point3D_id, xyz=xyz, rgb=rgb,
360 error=error, image_ids=image_ids,
361 point2D_idxs=point2D_idxs)
362 return points3D
363
364
365def write_points3D_text(points3D, path):

Callers 1

read_modelFunction · 0.85

Calls 2

read_next_bytesFunction · 0.85
Point3DClass · 0.50

Tested by

no test coverage detected