callum-canavan
commited on
Commit
·
cca580a
1
Parent(s):
609badf
Fix animation
Browse files- visual_anagrams/animate.py +14 -12
visual_anagrams/animate.py
CHANGED
@@ -118,21 +118,23 @@ def animate_two_view(
|
|
118 |
frames = frames[-hold_duration//2:] + frames[:-hold_duration//2]
|
119 |
images = frames
|
120 |
|
121 |
-
processed_frames = [images[0]]
|
122 |
|
123 |
-
for i in range(1, len(images)):
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
|
132 |
# Save the frames as a GIF
|
133 |
-
imageio.
|
134 |
-
|
135 |
-
|
|
|
|
|
136 |
|
137 |
|
138 |
|
|
|
118 |
frames = frames[-hold_duration//2:] + frames[:-hold_duration//2]
|
119 |
images = frames
|
120 |
|
121 |
+
# processed_frames = [images[0]]
|
122 |
|
123 |
+
# for i in range(1, len(images)):
|
124 |
+
# # Calculate the difference between current and previous frame
|
125 |
+
# diff = ImageChops.difference(images[i], images[i - 1])
|
126 |
+
# # Create a mask to isolate changes
|
127 |
+
# mask = diff.convert("L").point(lambda x: 0 if x < 5 else 255, "1")
|
128 |
+
# # Apply the mask to the current frame
|
129 |
+
# new_frame = ImageChops.composite(images[i], processed_frames[-1], mask)
|
130 |
+
# processed_frames.append(new_frame)
|
131 |
|
132 |
# Save the frames as a GIF
|
133 |
+
image_array = [imageio.core.asarray(frame) for frame in frames]
|
134 |
+
|
135 |
+
# Save as video
|
136 |
+
print('Making video...')
|
137 |
+
imageio.mimsave(save_video_path, image_array, fps=30)
|
138 |
|
139 |
|
140 |
|