From 0ab46ec66f57f6a4f861734ad467852f7842f6f3 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Sun, 15 Oct 2023 19:37:52 +0200 Subject: [PATCH] scripts/examples: Update examples. Remove sensor code that's not needed in some scripts. --- .../01-Video-Recording/imageio_read.py | 23 +++---------------- .../01-Video-Recording/imageio_write.py | 5 ++-- .../02-Image-Processing/00-Drawing/copy2fb.py | 15 ++---------- 3 files changed, 7 insertions(+), 36 deletions(-) diff --git a/scripts/examples/01-Camera/01-Video-Recording/imageio_read.py b/scripts/examples/01-Camera/01-Video-Recording/imageio_read.py index d1656ae8b..3b4d96313 100644 --- a/scripts/examples/01-Camera/01-Video-Recording/imageio_read.py +++ b/scripts/examples/01-Camera/01-Video-Recording/imageio_read.py @@ -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()) diff --git a/scripts/examples/01-Camera/01-Video-Recording/imageio_write.py b/scripts/examples/01-Camera/01-Video-Recording/imageio_write.py index 0878e5902..f9e797b64 100644 --- a/scripts/examples/01-Camera/01-Video-Recording/imageio_write.py +++ b/scripts/examples/01-Camera/01-Video-Recording/imageio_write.py @@ -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 diff --git a/scripts/examples/02-Image-Processing/00-Drawing/copy2fb.py b/scripts/examples/02-Image-Processing/00-Drawing/copy2fb.py index b2f3c3b73..fee673ee8 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/copy2fb.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/copy2fb.py @@ -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)