openmv/usr/examples/10-Tests/test_save.py
Kwabena W. Agyeman 94bc225542 Moved examples arround.
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.
2016-03-30 21:30:11 -04:00

112 lines
3.1 KiB
Python

import pyb, sensor, image, os, time
sensor.reset()
sensor.set_framesize(sensor.QVGA)
if not "test" in os.listdir(): os.mkdir("test")
while(True):
sensor.set_pixformat(sensor.GRAYSCALE)
for i in range(2):
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("test/image-%d" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("test/image-%d.bmp" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("test/image-%d.pgm" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("/test/image-%d" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("/test/image-%d.bmp" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("/test/image-%d.pgm" % num)
#
sensor.set_pixformat(sensor.RGB565)
for i in range(2):
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("test/image-%d" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("test/image-%d.bmp" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("test/image-%d.ppm" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("/test/image-%d" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("/test/image-%d.bmp" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("/test/image-%d.ppm" % num)
#
sensor.set_pixformat(sensor.JPEG)
for i in range(2):
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("test/image-%d" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("test/image-%d.jpg" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("test/image-%d.jpeg" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("/test/image-%d" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("/test/image-%d.jpg" % num)
#
img = sensor.snapshot()
num = pyb.rng()
print("Saving %d" % num)
img.save("/test/image-%d.jpeg" % num)
#
print("Sleeping 5...")
time.sleep(1000)
print("Sleeping 4...")
time.sleep(1000)
print("Sleeping 3...")
time.sleep(1000)
print("Sleeping 2...")
time.sleep(1000)
print("Sleeping 1...")
time.sleep(1000)