Img.replace Out of fast frame buffer stack memory

On an H7 R2, image replace of a grayscale QVGA image using HMIRROR and TRANSPOSE worked in FW V4.3.3, but in FW V 4.5.9 it causes an "Out of fast frame buffer stack memory.
Here is code that recreates the issue.

Image_Replace_Error_V1.py (513 Bytes)

This is a bug due to the addition of GPU support. A memory request for a color lookup table happens after all frame buffer ram is allocated for transpose.

The error will not happen on any camera that has SDRAM as the alloc_all which is exhausting memory is only issued to allocate all internal SRAM.

Also, the API has change for this. Replace/Set/Assign are all just aliases of draw_image now. They as binary operations (two arguments) and do not modify the destination image other than it’s pixels. Please use the unary image operations to modify an image with transpose.

import sensor
import time
import image

sensor.reset()
sensor.set_framesize(sensor.QVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_auto_gain(False)
sensor.set_auto_whitebal(False)
sensor.set_auto_exposure(False)

clock = time.clock()

while True:
    clock.tick()
    img = sensor.snapshot()
    img.scale(hint=image.HMIRROR | image.TRANSPOSE)

    print(clock.fps())

Use scale()/crop() as these are the unary operations which don’t change the pixel format. They are both aliases of each other. I couldn’t think of a good name for a generic unary image operation function that can scale, crop, mirror, transpose, flip. So, scale()/crop() are what’s there now.

Attached is an H7 firmware with a fix for this. This is from the tip of dev though which is undergoing major changes right now.
firmware.zip (1.1 MB)

imlib/draw: Fixed transpose on SDRAM-less boards. by kwagyeman · Pull Request #2508 · openmv/openmv