-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_gif.py
35 lines (24 loc) · 742 Bytes
/
main_gif.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import numpy as np
import matplotlib.pyplot as plt
import os
from tqdm import tqdm
from main import gen_rgbbase_and_normal, apply_illum
import shutil
fig = plt.figure()
N_seconds = 20
FPS = 20
N_frame = FPS * N_seconds
phi = np.linspace(0, 2 * np.pi, N_frame)
ims = []
os.mkdir('temp')
for i in tqdm(range(N_frame)):
rgbref_base, normal_base, cmap = gen_rgbbase_and_normal(seed=436,
rot=phi[i])
im = apply_illum(rgbref_base, normal_base, cmap)
plt.imsave("temp/out" + str(i) + ".png", im)
os.system(
"ffmpeg -r " + str(FPS) +
" -f image2 -s 1024x1024 -i temp/out%d.png -vcodec libx264 -crf 25 "
"-pix_fmt yuv420p test.mp4"
)
shutil.rmtree('temp')