MCPcopy Create free account
hub / github.com/OpenImagingLab/4DSloMo / read_colmap_bin_array

Function read_colmap_bin_array

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

259
260
261def read_colmap_bin_array(path):
262 """
263 Taken from https://github.com/colmap/colmap/blob/dev/scripts/python/read_dense.py
264
265 :param path: path to the colmap binary file.
266 :return: nd array with the floating point values in the value
267 """
268 with open(path, "rb") as fid:
269 width, height, channels = np.genfromtxt(fid, delimiter="&", max_rows=1,
270 usecols=(0, 1, 2), dtype=int)
271 fid.seek(0)
272 num_delimiter = 0
273 byte = fid.read(1)
274 while True:
275 if byte == b"&":
276 num_delimiter += 1
277 if num_delimiter >= 3:
278 break
279 byte = fid.read(1)
280 array = np.fromfile(fid, np.float32)
281 array = array.reshape((width, height, channels), order="F")
282 return np.transpose(array, (1, 0, 2)).squeeze()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected