0

I'm new to this forum and new to Pico. I'm currently working on a laser scanner using an OV5640 5Mpx I2C CAM and a Raspberry Pico. However, I'm encountering an issue when attempting to increase the image size to VGA (480 × 320): MemoryError: memory allocation failed, allocating 614400 bytes. I understand that Pico has a limit of 256KB of RAM.

Here is a part of my code (circuitpython):


import time
import busio
import board
import digitalio
import adafruit_ov5640
import usb_cdc
import gc

# Configuration de la caméra OV5640
bus = busio.I2C(board.GP9, board.GP8)
reset = digitalio.DigitalInOut(board.GP10)
cam = adafruit_ov5640.OV5640(
    bus,
    data_pins=(
        board.GP12,
        board.GP13,
        board.GP14,
        board.GP15,
        board.GP16,
        board.GP17,
        board.GP18,
        board.GP19,
    ),
    clock=board.GP11,
    vsync=board.GP7,
    href=board.GP21,
    mclk=board.GP20,
    shutdown=None,
    reset=reset,
    size=adafruit_ov5640.OV5640_SIZE_VGA, # 
)

# Configuration de la capture d'image
cam.colorspace = adafruit_ov5640.OV5640_COLOR_RGB # 
# cam.brightness = 1
# cam.saturation = 1
# cam.contrast = 1
# cam.exposure_value = -1
# cam.nightmode = False
# cam.quality = 54
# cam.white_balance = adafruit_ov5640.OV5640_WHITE_BALANCE_AUTO
cam.flip_y = True
cam.flip_x = False
cam.test_pattern = False

# Initialisation de t0
t0 = time.monotonic_ns()
# Create a variable to store the image
# Initial timestamp
image = bytearray(cam.capture_buffer_size)

# Main loop
while True:

    # Capture de l'image dans l'objet bytearray
    cam.capture(image)

    # Send the image buffer over USB
    usb_cdc.data.write(image)
    t1 = time.monotonic_ns()
    #print("Image Width:", cam.width)
    #print("Image Height:", cam.height)
    print("fps", 1e9 / (t1 - t0))
    t0 = t1

My question is: is there a way to allocate memory on an SD CARD, or stream data directly on it without RAM memory allocation, or to directly write data over serial until transfer is complete without memory allocation? Alternatively, is there a way to increase Pico RAM? For my project, I need to capture at least a VGA-sized image.

Thanks for your help, guys.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.