openmv/usr/examples/06-Video-Recording/image_reader.py
Kwabena W. Agyeman dc6ab59cfd Add Image Writer/Reader
These two new classes allow you to record image data for later viewing
at the same speed the image data was recorded. Unlike GIF/MJPEG the
image data is stored on the file system completely uncompressed in
native frame buffer format making super fast reading and writing
possible. Recording VGA Grayscale at ~13 FPS is possible along with
playing it back. (That's about 30 Mb/s folks).

...

The motivation for writing these scripts is so that you can record video
of something like a line following track, take that video home, and work
on computer vision algorithms for that data.

These classes should make it a lot easier to use the camera at home now.
2017-06-11 15:53:43 -04:00

26 lines
775 B
Python

# Image Reader Example
#
# USE THIS EXAMPLE WITH A USD CARD!
#
# This example shows how to use the Image Reader object to replay snapshots of what your
# OpenMV Cam saw saved by the Image Writer object for testing machine vision algorithms.
import sensor, image, time
snapshot_source = False # Set to true once finished to pull data from sensor.
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
img_reader = None if snapshot_source else image.ImageReader("/stream.bin")
while(True):
clock.tick()
img = sensor.snapshot() if snapshot_source else img_reader.next_frame(copy_to_fb=True, loop=True)
# Do machine vision algorithms on the image here.
print(clock.fps())