Closed fjremnav closed 3 years ago
def read_flo_file(filename, memcached=False):
"""
Read from Middlebury .flo file
:param flow_file: name of the flow file
:return: optical flow data in matrix
"""
if memcached:
filename = io.BytesIO(filename)
f = open(filename, 'rb')
magic = np.fromfile(f, np.float32, count=1)[0]
data2d = None
if 202021.25 != magic:
print('Magic number incorrect. Invalid .flo file')
else:
w = np.fromfile(f, np.int32, count=1)[0]
h = np.fromfile(f, np.int32, count=1)[0]
data2d = np.fromfile(f, np.float32, count=2 * w * h)
# reshape data into 3D array (columns, rows, channels)
data2d = np.resize(data2d, (1, h, w, 2))
f.close()
np.save("xxx.pkl", data2d)
return data2d
Why did you close this? did you find a solution?
How do I use test.py with optical flow info from a .flo file instead of .pkl?
Thanks,