openmv/scripts/examples/01-Camera/00-Snapshot/emboss_snapshot.py
2023-07-05 19:03:37 +02:00

33 lines
886 B
Python

# Emboss Snapshot Example
#
# Note: You will need an SD card to run this example.
#
# You can use your OpenMV Cam to save modified image files.
import sensor
import pyb
RED_LED_PIN = 1
BLUE_LED_PIN = 3
sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
sensor.skip_frames(time=2000) # Wait for settings take effect.
pyb.LED(RED_LED_PIN).on()
sensor.skip_frames(time=2000) # Give the user time to get ready.
pyb.LED(RED_LED_PIN).off()
pyb.LED(BLUE_LED_PIN).on()
print("You're on camera!")
img = sensor.snapshot()
img.morph(1, [+2, +1, +0, +1, +1, -1, +0, -1, -2]) # Emboss the image.
img.save("example.jpg") # or "example.bmp" (or others)
pyb.LED(BLUE_LED_PIN).off()
print("Done! Reset the camera to see the saved image.")