feat(cam): support format conversion function

This commit is contained in:
gaoxu
2025-08-26 17:16:56 +08:00
committed by BOT
parent f7ddaefdc5
commit de3e6d22e3
14 changed files with 256 additions and 3 deletions
@@ -30,4 +30,15 @@ menu "Example Configuration"
int
default 480 if EXAMPLE_CAM_VRES_480
default 240 if EXAMPLE_CAM_VRES_240
choice EXAMPLE_CAM_INPUT_FORMAT
bool "Set camera input format"
default EXAMPLE_CAM_INPUT_FORMAT_YUV422
config EXAMPLE_CAM_INPUT_FORMAT_RGB565
bool "RGB565"
config EXAMPLE_CAM_INPUT_FORMAT_YUV422
bool "YUV422"
endchoice
endmenu
@@ -146,7 +146,11 @@ void app_main(void)
.clk_src = CAM_CLK_SRC_DEFAULT,
.h_res = CONFIG_EXAMPLE_CAM_HRES,
.v_res = CONFIG_EXAMPLE_CAM_VRES,
#if CONFIG_EXAMPLE_CAM_INPUT_FORMAT_YUV422
.input_data_color_type = CAM_CTLR_COLOR_YUV422,
#else
.input_data_color_type = CAM_CTLR_COLOR_RGB565,
#endif
.dma_burst_size = 64,
.pin = &pin_cfg,
.bk_buffer_dis = 1,
@@ -200,6 +204,20 @@ void app_main(void)
//--------Enable and start Camera Controller----------//
ESP_ERROR_CHECK(esp_cam_ctlr_enable(cam_handle));
#if CONFIG_EXAMPLE_CAM_INPUT_FORMAT_YUV422
ESP_LOGI(TAG, "Configure format conversion: YUV422 -> RGB565");
// Configure format conversion
const cam_ctlr_format_conv_config_t conv_cfg = {
.src_format = CAM_CTLR_COLOR_YUV422, // Source format: YUV422
.dst_format = CAM_CTLR_COLOR_RGB565, // Destination format: RGB565
.conv_std = COLOR_CONV_STD_RGB_YUV_BT601,
.data_width = 8,
.input_range = COLOR_RANGE_LIMIT,
.output_range = COLOR_RANGE_LIMIT,
};
ESP_ERROR_CHECK(esp_cam_ctlr_format_conversion(cam_handle, &conv_cfg));
#endif
if (esp_cam_ctlr_start(cam_handle) != ESP_OK) {
ESP_LOGE(TAG, "Driver start fail");
return;
@@ -43,7 +43,11 @@ extern "C" {
#define EXAMPLE_DVP_CAM_BUF_ALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA)
#endif
#if CONFIG_EXAMPLE_CAM_INPUT_FORMAT_YUV422
#define EXAMPLE_CAM_FORMAT "DVP_8bit_20Minput_YUV422_240x240_25fps" // ov2640
#elif CONFIG_EXAMPLE_CAM_INPUT_FORMAT_RGB565
#define EXAMPLE_CAM_FORMAT "DVP_8bit_20Minput_RGB565_240x240_25fps" // ov2640
#endif
#ifndef EXAMPLE_CAM_FORMAT
#error "Unsupported camera format! Please adjust EXAMPLE_CAM_HRES and EXAMPLE_CAM_VRES in menuconfig"