Update app.py
Browse files
app.py
CHANGED
|
@@ -190,4 +190,22 @@ plot(grid)
|
|
| 190 |
# Once the .jpg flow images are saved, you can convert them into a video or a
|
| 191 |
# GIF using ffmpeg with e.g.:
|
| 192 |
#
|
| 193 |
-
# ffmpeg -f image2 -framerate 30 -i predicted_flow_%d.jpg -loop -1 flow.gif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
# Once the .jpg flow images are saved, you can convert them into a video or a
|
| 191 |
# GIF using ffmpeg with e.g.:
|
| 192 |
#
|
| 193 |
+
# ffmpeg -f image2 -framerate 30 -i predicted_flow_%d.jpg -loop -1 flow.gif
|
| 194 |
+
|
| 195 |
+
def write_flo(filename, flow):
|
| 196 |
+
"""
|
| 197 |
+
write optical flow in Middlebury .flo format
|
| 198 |
+
:param flow: optical flow map
|
| 199 |
+
:param filename: optical flow file path to be saved
|
| 200 |
+
:return: None
|
| 201 |
+
"""
|
| 202 |
+
f = open(filename, 'wb')
|
| 203 |
+
magic = np.array([202021.25], dtype=np.float32)
|
| 204 |
+
(height, width) = flow.shape[0:2]
|
| 205 |
+
w = np.array([width], dtype=np.int32)
|
| 206 |
+
h = np.array([height], dtype=np.int32)
|
| 207 |
+
magic.tofile(f)
|
| 208 |
+
w.tofile(f)
|
| 209 |
+
h.tofile(f)
|
| 210 |
+
flow.tofile(f)
|
| 211 |
+
f.close()
|