scripts/examples: Update examples.

Remove sensor code that's not needed in some scripts.
This commit is contained in:
iabdalkader 2023-10-15 19:37:52 +02:00
parent e9ef4cda2d
commit 0ab46ec66f
3 changed files with 7 additions and 36 deletions

View File

@ -2,33 +2,16 @@
#
# NOTE: This example requires an SD 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.
#
# Altered to allow full speed reading from SD card for extraction of sequences to the network etc.
# Set the new pause parameter to false
# This example shows how to use the Image Reader object to replay a raw video file.
import sensor
import image
import time
snapshot_source = False # Set to true once finished to pull data from sensor.
stream = image.ImageIO("/stream.bin", "r")
sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QQVGA) # Set frame size to QQVGA (160x120)
sensor.skip_frames(time=2000) # Wait for settings take effect.
clock = time.clock() # Create a clock object to track the FPS.
stream = None
if snapshot_source is False:
stream = image.ImageIO("/stream.bin", "r")
while True:
clock.tick()
if snapshot_source:
img = sensor.snapshot()
else:
img = stream.read(copy_to_fb=True, loop=True, pause=True)
img = stream.read(copy_to_fb=True, loop=True, pause=True)
# Do machine vision algorithms on the image here.
print(clock.fps())

View File

@ -2,9 +2,8 @@
#
# NOTE: This example requires an SD card.
#
# This example shows how to use the Image Writer object to record snapshots of what your
# OpenMV Cam sees for later analysis using the Image Reader object. Images written to disk
# by the Image Writer object are stored in a simple file format readable by your OpenMV Cam.
# This example shows how to use the Image Writer object to record a raw video file
# for later analysis using the Image Reader object.
import sensor
import image

View File

@ -1,23 +1,12 @@
# Copy image to framebuffer.
#
# This example shows how to load and copy an image to framebuffer for testing.
# This example shows how to load and display an image.
import sensor
import image
import time
# Still need to init sensor
sensor.reset()
# Set sensor settings
sensor.set_contrast(1)
sensor.set_gainceiling(16)
# Set sensor pixel format
sensor.set_framesize(sensor.QQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
# Load image
img = image.Image("/example.bmp", copy_to_fb=True)
# Add a small delay to allow the IDE to read the loaded image.
time.sleep_ms(500)
time.sleep_ms(1000)