MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / read_flow

Function read_flow

CV/PWCNet/src/flow_vis.py:142–163  ·  view source on GitHub ↗

https://github.com/sampepose/flownet2-tf/blob/master/src/flowlib.py read optical flow from Middlebury .flo file :param filename: name of the flow file :return: optical flow data in matrix

(filename)

Source from the content-addressed store, hash-verified

140
141
142def read_flow(filename):
143 """
144 https://github.com/sampepose/flownet2-tf/blob/master/src/flowlib.py
145 read optical flow from Middlebury .flo file
146 :param filename: name of the flow file
147 :return: optical flow data in matrix
148 """
149 f = open(filename, 'rb')
150 magic = np.fromfile(f, np.float32, count=1)
151 data2d = None
152
153 if 202021.25 != magic:
154 print('Magic number incorrect. Invalid .flo file')
155 else:
156 w = np.fromfile(f, np.int32, count=1)
157 h = np.fromfile(f, np.int32, count=1)
158 print("Reading %d x %d flo file" % (h, w))
159 data2d = np.fromfile(f, np.float32, count=2 * w[0] * h[0])
160 # reshape data into 3D array (columns, rows, channels)
161 data2d = np.resize(data2d, (h[0], w[0], 2))
162 f.close()
163 return data2d

Callers

nothing calls this directly

Calls 1

resizeMethod · 0.80

Tested by

no test coverage detected