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)
| 259 | |
| 260 | |
| 261 | def 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() |
nothing calls this directly
no outgoing calls
no test coverage detected