Added Local animation testing script.
This allows animation development and testing on desktop only
This commit is contained in:
parent
e9ebf8bfb1
commit
a7d200ca82
1 changed files with 45 additions and 0 deletions
45
rpi/AnimationTester.py
Normal file
45
rpi/AnimationTester.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
from PIL import Image, ImageSequence
|
||||
from Point2D import generate_point_array_from_image, interpolate_point_pairs, generate_image_from_point_array, pair_points
|
||||
|
||||
# Load the two small images
|
||||
image1 = Image.open("/home/cisco/CiscoTheProot/eyeLeftOpen.png")
|
||||
image2 = Image.open("/home/cisco/CiscoTheProot/eyeLeftStunned.png")
|
||||
|
||||
# Generate point arrays from the images
|
||||
points1 = generate_point_array_from_image(image1)
|
||||
points2 = generate_point_array_from_image(image2)
|
||||
|
||||
# Pair the points from the two images
|
||||
point_pairs = pair_points(points1, points2)
|
||||
|
||||
# Generate ten frames of animation
|
||||
num_frames = 10
|
||||
frames = []
|
||||
|
||||
for i in range(num_frames):
|
||||
# Interpolate the points based on the frame number
|
||||
percentage = i / (num_frames - 1)
|
||||
interpolated_points = interpolate_point_pairs(point_pairs, percentage)
|
||||
|
||||
# Generate the image from the interpolated points
|
||||
width, height = image1.size
|
||||
frame_image = generate_image_from_point_array(interpolated_points, width, height)
|
||||
|
||||
# Append the frame image to the list of frames
|
||||
frames.append(frame_image)
|
||||
|
||||
# Save the frames as separate images
|
||||
for i, frame_image in enumerate(frames):
|
||||
frame_image.save(f"/home/cisco/CiscoTheProot/animations/frame_{i}.png")
|
||||
|
||||
# Save the frames as a GIF
|
||||
gif_filename = f"/home/cisco/CiscoTheProot/animations/animation.gif"
|
||||
frames[0].save(
|
||||
gif_filename,
|
||||
save_all=True,
|
||||
append_images=frames[1:]+frames[::-1],
|
||||
duration=200, # Specify the duration between frames (in milliseconds)
|
||||
loop=0 # Set loop to 0 for an infinite loop
|
||||
)
|
||||
|
||||
print("GIF animation saved as", gif_filename)
|
Loading…
Add table
Reference in a new issue