openmv/usr/examples/gif.py
Kwabena W. Agyeman 66248c444b Update Gif to use fb_alloc_all.
And tested it along with mjpeg to make sure all this stuff is good. I
also see the issue with QQVGA now. That just appeared.
2016-03-05 22:29:21 -05:00

31 lines
827 B
Python

# Gif recording example:
#
# You can use your OpenMV Cam to record gif files. You can either feed the
# recorder object RGB565 frames or Grayscale frames. Use photo editing software
# like GIMP to compress and optimize the Gif before uploading it to the web.
import sensor, image, time, gif
sensor.reset()
sensor.set_framesize(sensor.QQVGA)
sensor.set_pixformat(sensor.RGB565) # you can also use grayscale
# Warm up the cam
for i in range(10):
sensor.snapshot()
# FPS clock
clock = time.clock()
gif = gif.Gif("/test.gif", loop=True) # video setup to use current resolution
for i in range(30):
clock.tick()
img = sensor.snapshot()
gif.add_frame(img, delay=10) # centi seconds
# Print FPS.
# Note: Actual FPS is higher, the IDE slows down streaming.
print(clock.fps())
gif.close()
print("done")