mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
scripts/examples: Update examples.
Remove sensor code that's not needed in some scripts.
This commit is contained in:
parent
e9ef4cda2d
commit
0ab46ec66f
@ -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())
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user