Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

初始化摄像头.pixel_format = PIXFORMAT_RGB565后,修改为PIXFORMAT_JPEG出现的问题 #505

Closed
Letian-stu opened this issue Feb 10, 2023 · 1 comment

Comments

@Letian-stu
Copy link

Letian-stu commented Feb 10, 2023

你好,我一开始想初始化ov2640获取的像素格式为rgb565,在初始化成功后修改为jpge出现错误,能不能这样修改模式,我的代码如下:

static camera_config_t camera_config = {
    .pin_pwdn = CAM_PIN_PWDN,
    .pin_reset = CAM_PIN_RESET,
    .pin_xclk = CAM_PIN_XCLK,
    .pin_sccb_sda = CAM_PIN_SIOD,
    .pin_sccb_scl = CAM_PIN_SIOC,

    .pin_d7 = CAM_PIN_D7,
    .pin_d6 = CAM_PIN_D6,
    .pin_d5 = CAM_PIN_D5,
    .pin_d4 = CAM_PIN_D4,
    .pin_d3 = CAM_PIN_D3,
    .pin_d2 = CAM_PIN_D2,
    .pin_d1 = CAM_PIN_D1,
    .pin_d0 = CAM_PIN_D0,
    .pin_vsync = CAM_PIN_VSYNC,
    .pin_href = CAM_PIN_HREF,
    .pin_pclk = CAM_PIN_PCLK,

    .xclk_freq_hz = 20000000,
    .ledc_timer = LEDC_TIMER_0,
    .ledc_channel = LEDC_CHANNEL_0,

    .pixel_format = PIXFORMAT_RGB565,
    .frame_size = FRAMESIZE_QVGA, 
    .jpeg_quality = 32, 
    .fb_count = 1,                  
};
esp_err_t cam_config_init(void)
{
    esp_err_t err = esp_camera_init(&camera_config);
    if (err != ESP_OK)
    {
        ESP_LOGE(TAG, "Camera Init Failed");
        return ESP_FAIL;
    }
    else
    {
        ESP_LOGI(TAG, "Camera Init Succrss");
    }
    sensor_t *camera_cfg = esp_camera_sensor_get();
    camera_cfg->set_pixformat(camera_cfg, PIXFORMAT_JPEG );
    camera_cfg->set_framesize(camera_cfg, FRAMESIZE_QVGA );
    ESP_LOGE(TAG, "Camera Init change ok");
    return ESP_OK;
}

ESP-IDF Monitor 如下

I (0) cpu_start: Starting scheduler on APP CPU.
I (484) main: HELLO TIAN
I (487) init: Start Init
I (491) s3 ll_cam: DMA Channel=4
I (494) cam_hal: cam init ok
I (498) sccb: pin_sda 14 pin_scl 13
I (502) sccb: sccb_i2c_port=1
I (506) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (546) camera: Detected camera at address=0x30
I (548) camera: Detected OV2640 camera
I (548) camera: Camera PID=0x26 VER=0x42 MIDL=0x7f MIDH=0xa2
I (625) s3 ll_cam: node_size: 3840, nodes_per_line: 1, lines_per_node: 6
I (625) s3 ll_cam: dma_half_buffer_min:  3840, dma_half_buffer:  7680, lines_per_half_buffer: 12, dma_buffer_size: 15360
I (633) cam_hal: buffer_size: 15360, half_buffer_size: 7680, node_buffer_size: 3840, node_cnt: 4, total_cnt: 20
I (643) cam_hal: Allocating 153600 Byte frame buffer in PSRAM
I (650) cam_hal: cam config ok
I (653) ov2640: Set PLL: clk_2x: 1, clk_div: 3, pclk_auto: 1, pclk_div: 8
I(728) cam: Camera Init Succrss
I (743) ov2640: Set PLL: clk_2x: 0, clk_div: 0, pclk_auto: 0, pclk_div: 8
E (743) cam_hal: FB-SIZE: 0 != 153600

assert failed: spinlock_acquire spinlock.h:123 ((result == SPINLOCK_FREE) == (lock->count == 0))        


Backtrace:0x40375cde:0x3fcf3d700x4037aab5:0x3fcf3d90 0x403817f5:0x3fcf3db0 0x4037ddf5:0x3fcf3ed0 0x4037b893:0x3fcf3f10 0x4200b3b9:0x3fcf3f50 0x4200719e:0x3fcf3f90 0x42007281:0x3fcf3fc0 0x42007b60:0x3fcf3fe0 0x42007c56:0x3fcf4030 0x42005f99:0x3fcf4060 0x42005f30:0x3fcf4080 0x42005ec2:0x3fcf40a0 0x4201cb54:0x3fcf40c0 0x4037dbd9:0x3fcf40e0
0x40375cde: panic_abort at D:/B_Code/espidf/esp32idf/esp-idf/components/esp_system/panic.c:402

0x4037aab5: esp_system_abort at D:/B_Code/espidf/esp32idf/esp-idf/components/esp_system/esp_system.c:128

0x403817f5: __assert_func at D:/B_Code/espidf/esp32idf/esp-idf/components/newlib/assert.c:85

0x4037ddf5: spinlock_acquire at D:/B_Code/espidf/esp32idf/esp-idf/components/esp_hw_support/include/soc/spinlock.h:123
 (inlined by) xPortEnterCriticalTimeout at D:/B_Code/espidf/esp32idf/esp-idf/components/freertos/port/xtensa/port.c:288

0x4037b893: vPortEnterCritical at D:/B_Code/espidf/esp32idf/esp-idf/components/freertos/port/xtensa/include/freertos/portmacro.h:578
 (inlined by) xQueueReceive at D:/B_Code/espidf/esp32idf/esp-idf/components/freertos/queue.c:1400

0x4200b3b9: i2c_master_cmd_begin at D:/B_Code/espidf/esp32idf/esp-idf/components/driver/i2c.c:1481

0x4200719e: SCCB_Write at D:/C_Github/ESP32S3-Sr-Bafacloud-Wxapp-Project/Software/ESP32_Project/components/esp32-camera/driver/sccb.c:151
0x42007b60: set_window at D:/C_Github/ESP32S3-Sr-Bafacloud-Wxapp-Project/Software/ESP32_Project/components/esp32-camera/sensors/ov2640.c:197

0x42007c56: set_framesize at D:/C_Github/ESP32S3-Sr-Bafacloud-Wxapp-Project/Software/ESP32_Project/components/esp32-camera/sensors/ov2640.c:244

0x42005f99: cam_config_init at D:/C_Github/ESP32S3-Sr-Bafacloud-Wxapp-Project/Software/ESP32_Project/main/cam_task/cam_task.c:62 (discriminator 3)

0x42005f30: Init_Config at D:/C_Github/ESP32S3-Sr-Bafacloud-Wxapp-Project/Software/ESP32_Project/main/Init_Config/initconfig.c:35

0x42005ec2: app_main at D:/C_Github/ESP32S3-Sr-Bafacloud-Wxapp-Project/Software/ESP32_Project/main/main.c:21

0x4201cb54: main_task at D:/B_Code/espidf/esp32idf/esp-idf/components/freertos/port/port_common.c:141 (discriminator 2)

0x4037dbd9: vPortTaskWrapper at D:/B_Code/espidf/esp32idf/esp-idf/components/freertos/port/xtensa/port.c:131
@WangYuxin-esp
Copy link
Contributor

这个sensor 不支持直接更改输出格式。需要重新调用 esp_camera_init() 更改输出格式。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants