mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Tried to emulate Arduino's 11 folders... I'd perfer to have all the shield scripts in one folder... but, that might not make sense. I don't really want one script per folder however. So, I might merge some more stuff in the future. I have a grand idea here that will become evident as I work though the examples. Anyway, the current structure is not final. It will be in flux for a little while. As for Git History, folder history is the best we're going to get. Git and GitHub don't seem to deal with moves too well.
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
# GIF Video Recording Example
|
|
#
|
|
# Note: You will need an SD card to run this 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, pyb
|
|
|
|
RED_LED_PIN = 1
|
|
BLUE_LED_PIN = 3
|
|
|
|
sensor.reset() # Initialize the camera sensor.
|
|
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
|
|
sensor.set_framesize(sensor.QQVGA) # or sensor.QVGA (or others)
|
|
sensor.skip_frames() # Let new settings take affect.
|
|
clock = time.clock() # Tracks FPS.
|
|
|
|
pyb.LED(RED_LED_PIN).on()
|
|
sensor.skip_frames(30) # Give the user time to get ready.
|
|
|
|
pyb.LED(RED_LED_PIN).off()
|
|
pyb.LED(BLUE_LED_PIN).on()
|
|
|
|
gif = gif.Gif("demo.gif", loop=True)
|
|
|
|
print("You're on camera!")
|
|
for i in range(100):
|
|
clock.tick()
|
|
# clock.avg() returns the milliseconds between frames - gif delay is in
|
|
gif.add_frame(sensor.snapshot(), delay=int(clock.avg()/10)) # centiseconds.
|
|
print(clock.fps())
|
|
|
|
gif.close()
|
|
pyb.LED(BLUE_LED_PIN).off()
|
|
print("Done! Reset the camera to see the saved recording.")
|