Memory read errors with v4.5.2

Openmv H7 Plus using modified example works on older firmware v4.2.3 but non on v4.5.2.

stream.read(copy_to_fb=current_frame, loop=False, pause=False) fails with “TypeError: can’t convert Image to int”

Code to reproduce:


# This work is licensed under the MIT license.
# Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Image Memory Stream I/O Example
#
# This example shows how to use the ImageIO stream to record frames in memory and play them back.
# Note: While this should work on any board, the board should have an SDRAM to be of any use.
import sensor
import image
import time

# Number of frames to pre-allocate and record
N_FRAMES = 500

sensor.reset()  # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QQQVGA) #resolution

# This frame size must match the image size passed to ImageIO
sensor.set_windowing((57, 24))

sensor.skip_frames(time=2000)

clock = time.clock()

# Write to memory stream
stream = image.ImageIO((57, 24, sensor.GRAYSCALE), N_FRAMES)



for i in range(0, N_FRAMES):
    clock.tick()
    stream.write(sensor.snapshot())
    print(clock.fps())
    
stream.seek(0)
current_frame = stream.read(copy_to_fb=False, loop=False, pause=False)
stream.seek(0)

while True:
    # Rewind stream and play back
    stream.seek(0)
    for i in range(0, N_FRAMES):
        img = stream.read(copy_to_fb=current_frame, loop=False, pause=False)
        # Do machine vision algorithms on the image here.

Hi, the API changed.

We removed copy_to_fb copying directory to images. You can pass True to False. But, not another image object. This feature was to hard to maintain and creates mind-bending code complexity.

@kwagyeman a) Could you please let me know the latest firmware version where I can pass another image object in the function. and b) an alterative way to realize the same thing with other functions ? Thanks.

Hi,

a) This is detailed in the release notes for each firmware. Look for any changes related to the Image() method.
b) Just copy it to the main frame buffer and then use the replace()/assign()/set() methods to copy to the target buffer. Yes, this is technically another copy. This will be the functionality for the mean time.