Skip to content

Color distorted on ov5647 (AEGHB-907) #16

Description

@mutatrum

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate
  • Read the documentation to confirm the issue is not addressed there and your configuration is set correctly
  • Tested with the latest version to ensure the issue hasn't been fixed

How often does this bug occurs?

always

Expected behavior

Proper color reproduction. I have a test image, picture takes with my phone:

image

Colors are good when running f.e. the simple_video_server_example:

image

Picture is flipped, but color reproduction is correct.

Actual behavior (suspected bug)

I'm trying to capture frames and show them on an LVGL 9 RGB565 canvas, on an ST7789 display. I push the frame to the canvas, I get the following result:

image

The display is only 320x240, and this is unscaled so it's a small crop of the frame buffer.

Error logs or terminal output

No response

Steps to reproduce the behavior

I've takes the setup code from the esp_video_server_example, set up the capture format:

    struct v4l2_format format = {
        .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
        .fmt.pix.width = 800,
        .fmt.pix.height = 800,
        .fmt.pix.pixelformat = V4L2_PIX_FMT_RGB565,
    };

    if (ioctl(fd, VIDIOC_S_FMT, &format) != 0) {
        ESP_LOGE(TAG, "failed to set format");
        goto exit_0;
    }

Reading back the format shows it's set up as RGB565.

The deviation from the video_server_example is the capture loop, instead of reading the fd and push it into a JPEG converter, I push the frame directly onto an lv_image:

    lv_image_dsc_t img_dsc = {
        .header = {
            .magic = LV_IMAGE_HEADER_MAGIC,
            .cf = LV_COLOR_FORMAT_RGB565,
            .w = 800,
            .h = 800,
        }
    };

    while (1) {
        memset(&buf, 0, sizeof(buf));
        buf.type   = type;
        buf.memory = MEMORY_TYPE;

        esp_err_t res = ioctl(video_fd, VIDIOC_DQBUF, &buf);
        if (res != 0) {
            ESP_LOGE(TAG, "failed to receive video frame");
            break;
        }

        lvgl_port_lock(0);

        img_dsc.data_size = buf.bytesused;
        img_dsc.data = buffer[buf.index];
        lv_image_set_src(img1, &img_dsc);

        lv_refr_now(NULL);

        lvgl_port_unlock();

        if (ioctl(video_fd, VIDIOC_QBUF, &buf) != 0) {
            ESP_LOGE(TAG, "failed to free video frame");
        }
   }

Project release version

0.7.0

System architecture

Intel/AMD 64-bit (modern PC, older Mac)

Operating system

Linux

Operating system version

Ubuntu 24.04

Shell

Bash

Additional context

ESP32P4 Function Evaluation Board chip revision: v0.1

ESP-IDF v5.4-dev-4291-g7a305c0284-dirty 2nd stage bootloader

Dependencies:

[1/9] espressif/cmake_utilities (0.5.3)
[2/9] espressif/esp_cam_sensor (0.7.0)
[3/9] espressif/esp_h264 (1.0.4)
[4/9] espressif/esp_ipa (0.1.0)
[5/9] espressif/esp_lvgl_port (2.4.2)
[6/9] espressif/esp_sccb_intf (0.0.4)
[7/9] espressif/esp_video (0.7.0)
[8/9] lvgl/lvgl (9.2.2)
[9/9] idf (5.5.0)

Maybe similar to #8 ?

The only setting in sdkconfig.default is CONFIG_CAMERA_OV5647=y, the rest is not altered from default value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions