openmv/usr/examples/05-Picture-Taking/write_jpeg.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

34 lines
701 B
Python

import sensor, pyb, time
# Reset sensor
sensor.reset()
# Set sensor settings
sensor.set_brightness(0)
sensor.set_saturation(0)
sensor.set_gainceiling(16)
sensor.set_contrast(1)
sensor.set_framesize(sensor.QVGA)
# Enable JPEG and set quality
sensor.set_pixformat(sensor.JPEG)
sensor.set_quality(98)
# Red LED
led = pyb.LED(1)
# Skip a few frames to allow the sensor settle down
# Note: This takes more time when exec from the IDE.
for i in range(0, 30):
sensor.snapshot()
# Turn on red LED and wait for a second
led.on()
time.sleep(1000)
# Write JPEG image to file
with open("/test.jpeg", "w") as f:
f.write(sensor.snapshot())
led.off()
print("Reset the camera to see the saved image.")