MCPcopy
hub / github.com/cvg/Hierarchical-Localization / read_points3D_binary

Function read_points3D_binary

hloc/utils/read_write_model.py:338–365  ·  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

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

Callers 1

read_modelFunction · 0.85

Calls 1

read_next_bytesFunction · 0.85

Tested by

no test coverage detected