openmv/usr/examples/gif.py
Kwabena W. Agyeman 9325029675 Add support for color gif.
Color gifs look very good for how bad you'd expect them to be with just
7 bits of color (rgb232) - quite amazing. Also, I  hardened the gif
module to make it "user ready".
2016-03-04 23:30:01 -05:00

31 lines
611 B
Python

import time, sensor, image, gif
# Reset sensor
sensor.reset()
# Set sensor settings
sensor.set_contrast(1)
sensor.set_brightness(1)
sensor.set_saturation(1)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.QQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
for i in range(30):
img = sensor.snapshot()
# FPS clock
clock = time.clock()
gif = gif.Gif("/test.gif", loop=True)
for i in range(30):
clock.tick()
img = sensor.snapshot()
gif.add_frame(img, delay=10)
# Print FPS.
# Note: Actual FPS is higher, the IDE slows down streaming.
print(clock.fps())
gif.close()
print("done")