MCPcopy Create free account
hub / github.com/ComputationalRobotics/XM-code / load_matrix_from_bin

Function load_matrix_from_bin

utils/io.py:35–54  ·  view source on GitHub ↗
(filename, byte = 4)

Source from the content-addressed store, hash-verified

33 print("Cannot write to file")
34
35def load_matrix_from_bin(filename, byte = 4):
36 try:
37 with open(filename, "rb") as file:
38 if byte == 4:
39 rows = int.from_bytes(file.read(4), byteorder='little')
40 cols = int.from_bytes(file.read(4), byteorder='little')
41 elif byte == 8:
42 rows = int.from_bytes(file.read(8), byteorder='little', signed=False)
43 cols = int.from_bytes(file.read(8), byteorder='little', signed=False)
44
45 n = rows
46
47 matrix = np.fromfile(file, dtype=np.double, count=rows * cols)
48 matrix = matrix.reshape((rows, cols), order='F')
49
50 print(f"rows: {rows}, cols: {cols}")
51 return matrix, n
52 except IOError:
53 print("Cannot open file")
54 return None, None
55
56def save_array_to_bin(filename, array):
57 """

Callers 6

4_test_unidepth.pyFile · 0.90
5_test_ceres.pyFile · 0.90
load_BAL_gtFunction · 0.90
load_gt_depthFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected