MCPcopy Create free account
hub / github.com/Atrovast/THGS / read_colmap_bin_array

Function read_colmap_bin_array

scene/colmap_loader.py:273–294  ·  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

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected