Hello to all,
i’ll try to create a white reference picture on the fly on my H7 camera.
Therefore i create a extra framebuffer and draw a white rectangle in the framebuffer.
For debugging purpose i’d like to show the extra frame buffer in the IDE.
Here is my code snipped:
print(int(x),int(y),int(width),int(height))
#create reference picture white
print(sensor.width())
print(sensor.height())
img1 = sensor.alloc_extra_fb(sensor.width(),sensor.height(), sensor.RGB565)
#img1 = sensor.alloc_extra_fb(xstep, ystep, sensor.RGB565)
#img1 = image.Image(xstep,ystep,sensor.BINARY,True)
#img1.replace(sensor.snapshot())
img1.clear()
img1.crop(roi=(0, 0, int(width),int(height)))
img1.draw_rectangle(0,0,int(width),int(height),color=(255,255,255),fill=True)
i = 0
while(True):
i += 1
print(img1.compressed_for_ide(), end="")
print(i)
utime.sleep_ms(100)
When i try to show the frame buffer with the line:
print(img1.compress_for_ide(), end="")
The IDE crashes with the error message:
“OSError: The new image won’t fit in the target buffer!”
Why is the buffer not large enough? The rectangle ist width = 548 and height = 325.
The memory is allocated with 800 x 600.
When i change it to the line mentioned above
print(img1.compressed_for_ide(), end="")
the while loop does 7 till 8 iterations, then crashes with:
“MemoryError: memory allocation failed, allocation xxx bytes”
what do i wrong? Have to be the memory not allocated only once?
Is there a easier method to create a plain reference picture on the fly?
Thanks in advantage.