LVGL little camera reading information real time, micropython

Description

What MCU/Processor/Board and compiler are you using?

I am working with K210 module and using the CanMV IDE usingmicropython

What LVGL version are you using?

lvgl little

What do you want to achieve?

t make images from the camera be show in a GUI frame created

What have you tried so far?

I tried coding but it does not work

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:


class Frame:
    def __init__(self, parent):
        # Create a frame object inside the parent tab
        self.frame_obj = lv.obj(parent)
        self.frame_obj.set_size(220, 220)
        self.frame_obj.align(parent, lv.ALIGN.CENTER, 0, 0)

        # Initialize the camera (GC2145 sensor)
        sensor.reset()
        sensor.set_pixformat(sensor.RGB565)  # Set color format (RGB565 for LCD compatibility)
        sensor.set_framesize(sensor.QVGA)    # 320x240 resolution
        sensor.skip_frames(time=2000)        # Let the camera adjust

        # Create an LVGL image object inside the frame
        self.img_display = lv.img(self.frame_obj)
        self.img_display.set_size(220, 220)
        self.img_display.align(self.frame_obj, lv.ALIGN.CENTER, 0, 0)

        # Create an LVGL image descriptor
        self.img_dsc = lv.img_dsc_t()
        self.img_dsc.header.always_zero = 0
        self.img_dsc.header.cf = lv.img.CF.TRUE_COLOR
        self.img_dsc.header.w = 320
        self.img_dsc.header.h = 240
        self.img_dsc.data_size = 320 * 240 * 2  # RGB565 (2 bytes per pixel)
        self.img_dsc.data = bytearray(self.img_dsc.data_size)  # Create a buffer

        # Start a timer to update the frame regularly
        self.timer = Timer(1)
        self.timer.init(period=100, mode=Timer.PERIODIC, callback=self.update_frame)

    def update_frame(self, t):
        img = sensor.snapshot()  # Capture an image from the camera
        img_data = img.copy().to_bytes()  # Convert to a properly formatted bytearray

        # Update the LVGL image descriptor with new frame data
        self.img_dsc.data = img_data  # Assign the new image data

        # Update LVGL display
        self.img_display.set_src(self.img_dsc)  # Set the updated image
        self.img_display.invalidate()  # Force LVGL to refresh the display  

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.