Frame buffer overflow! How to adjust the Frame buffer without changing the code

I downloaded the firmware from OpenMV · GitHub for openmv4,and copied the main.py to the disk,The program is running normally.

but to freeze scripts to do the following:
1 Add the boot.py to the libraries folder.
2 Edit the manifest.py in the boards/OPENMV4,adding freeze (“$(OMV_LIB_DIR)/”, “boot.py”) to the manifest.py file
3 generate the firmware image for your OpenMV Cam.

when use diy firmware,I got the error message from uart,“Traceback (most recent call last):
File “boot.py”, line 85, in
RuntimeError: Frame buffer overflow, try reducing the frame size.
OpenMV 5fb041dc9a; MicroPython 7c5ab76686; OPENMV4 with STM32H743,”

How to adjust the Frame buffer of the openmv4 without changing the code from sensor.VGA to sensor.QVGA?

the codes of the boot.py is below:
import sensor, time
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(time=200)
clock = time.clock()
def find_light_spots(img):
blobs = img.find_blobs([(200, 255)],
area_threshold=20,
merge=True,
margin=2
)
lastBlobs =
for blob in blobs:
if (blob.area() < 400):
if blob.roundness() > 0.4 and blob.density() > 0.5:
lastBlobs.append(blob)
detected =
if len(lastBlobs) >= 1:
lastBlobs.sort(key=lambda b: b.area(), reverse=True)
detected = [(b.cx(), b.cy()) for b in lastBlobs[:min(2, len(lastBlobs))]]
return detected
def show_debug_info(img, spots):
img.draw_string(5, 5, f"blob Num {len(spots)}“, color=255, scale=2)
if len(spots) == 0:
return
colors = [255, 200]
for i, (u, v) in enumerate(spots):
img.draw_circle(int(u), int(v), 6, color=colors[i])
img.draw_string(int(u)+5, int(v)-20, f"P{i}”, color=255)
img.draw_string(5, 20+15i, f"P{i}: ({spots[i][0]}, {spots[i][1]})“, color=200, scale=fontScale)
try:
while True:
img = sensor.snapshot()
spots = find_light_spots(img)
if debug:
show_debug_info(img, spots)

except KeyboardInterrupt:
print(“\nsystem is stopped”)

Hi

I had the same issue with using grayscale VGA on the H7 a while ago. Seems the framebuffer architecture has been changed in a way that uses more memory now, which the H7 doesn’t have.

See details here: V4.8.1. breaking VGA on H7

And this is the commit with the changes I’ve implemented on my fork to fix it: Changed to fixed 1 byte/pixel framebuffer for H7 · falthaus/openmv@a004937 · GitHub

Maybe this helps
Felix

I’ve made a bug tracker for this issue: Examine if using 1bpp is possible with new CSI FB Arch. · Issue #3103 · openmv/openmv · GitHub

It might not be possible, but I will examine if it’s fixable. Note that this may not make it into the V5.0.0 release.

I found an easy way to fix this with the new csi API: modules: Add raw_bpp control from py_csi_ng. by kwagyeman · Pull Request #3104 · openmv/openmv · GitHub

thanks for your reply,It’s perfect.

thanks for your reply,I changed 1byte/pixel for my H7