openmv/scripts/examples/01-Camera/03-Event-Cameras/frogeye2020.py
2022-09-01 00:02:30 +02:00

40 lines
947 B
Python

# This example shows off using the frogeye2020 event camera.
#
# The frogeye2020 is a 320x240 event camera. There are two bits per pixel which show no motion,
# motion in one direction, or motion in another direction. The sensor runs at 50 FPS.
import sensor, image, time
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
palette = image.Image(1, 256, sensor.RGB565)
for i in range(64):
palette.set_pixel(0, i, (0, 0, 0))
for i in range(64, 128):
palette.set_pixel(0, i, (255, 0, 0))
for i in range(128, 192):
palette.set_pixel(0, i, (0, 0, 255))
for i in range(192, 256):
palette.set_pixel(0, i, (0, 255, 0))
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
# Handle sensor rotation.
img.assign(hmirror=True, vflip=True)
# Make pretty.
img.to_rainbow(color_palette=palette)
# Cleanup noise.
img.erode(1)
print(clock.fps())