MCPcopy Create free account
hub / github.com/NVlabs/InstantSplat / read_colmap_bin_array

Function read_colmap_bin_array

scene/colmap_loader.py:277–298  ·  view source on GitHub ↗

Taken from https://github.com/colmap/colmap/blob/dev/scripts/python/read_dense.py :param path: path to the colmap binary file. :return: nd array with the floating point values in the value

(path)

Source from the content-addressed store, hash-verified

275
276
277def read_colmap_bin_array(path):
278 """
279 Taken from https://github.com/colmap/colmap/blob/dev/scripts/python/read_dense.py
280
281 :param path: path to the colmap binary file.
282 :return: nd array with the floating point values in the value
283 """
284 with open(path, "rb") as fid:
285 width, height, channels = np.genfromtxt(fid, delimiter="&", max_rows=1,
286 usecols=(0, 1, 2), dtype=int)
287 fid.seek(0)
288 num_delimiter = 0
289 byte = fid.read(1)
290 while True:
291 if byte == b"&":
292 num_delimiter += 1
293 if num_delimiter >= 3:
294 break
295 byte = fid.read(1)
296 array = np.fromfile(fid, np.float32)
297 array = array.reshape((width, height, channels), order="F")
298 return np.transpose(array, (1, 0, 2)).squeeze()
299
300
301def write_cameras_text(cameras, path):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected