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)
| 275 | |
| 276 | |
| 277 | def 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 | |
| 301 | def write_cameras_text(cameras, path): |
nothing calls this directly
no outgoing calls
no test coverage detected