Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/aaschaer/ShinyShadow
Browse files Browse the repository at this point in the history
  • Loading branch information
aaschaer committed Aug 3, 2019
2 parents f09238c + 5e726b3 commit e748874
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.pyc
__pycache__
*.mp4
__pycache__
frames/
44 changes: 44 additions & 0 deletions prediction_vid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import matplotlib.pyplot as plt
import imageio
import numpy
import os

from conversion import *
from walk_analysis import paths


def create_frames(cors):
"""
For each cordinate pair, output a graph to be used as a frame
"""

for i in range(len(cors)):
fig = plt.figure()
plt.ylim(-50, 50)
plt.xlim(-50, 50)

plt.plot(cors[i][0], cors[i][1], "ro")
fig.savefig("frames/{}.png".format(i))
plt.close()


def create_video():
"""
Merges images in /frames into a 60 fps prediction video
"""
fnames = os.listdir("frames/")
fnames.sort(key= lambda a : int(a[:-4]))
videowriter = imageio.get_writer('prediction_video.mp4', fps=60)
for fname in fnames:
videowriter.append_data(plt.imread("frames/{}".format(fname)))
videowriter.close()


positions = []
for path in paths:
for c in path:
positions.append((hex_str_to_single(c[0]),
hex_str_to_single(c[1])))

create_frames(positions)
create_video()

0 comments on commit e748874

Please sign in to comment.