Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ESP32-CAM buffer

When I initialize the camera I use this:

#include "esp_camera.h"

bool initCamera(){
    Serial.print("Iniciando Cámara ...");
    camera_config_t config;
    config.ledc_channel = LEDC_CHANNEL_0;
    config.ledc_timer = LEDC_TIMER_0;
    config.pin_d0 = Y2_GPIO_NUM;
    ...

        ...
    config.xclk_freq_hz = 20000000;
    config.pixel_format = PIXFORMAT_JPEG;
    config.frame_size = FRAMESIZE_XGA;
    config.jpeg_quality = 8;
    config.fb_count = 1;
    config.grab_mode = CAMERA_GRAB_LATEST; <<<<<<< 

    // camera init
    esp_err_t err = esp_camera_init(&config);
    if (err != ESP_OK){
        Serial.printf("... error 0x%x", err);
        return false;
    }

    sensor_t *s = esp_camera_sensor_get();
    Serial.println("... OK");
    CAMARA_OK = true;
    return true;
}

But when I ask for a capture:

static esp_err_t capture_handler(httpd_req_t *req){

    cambiosConfiguracion(req);

    camera_fb_t *fb = NULL;
    esp_err_t res = ESP_OK;

    fb = esp_camera_fb_get();

    if (!fb){

        Serial.println("Camera capture failed");
        httpd_resp_send_500(req);
        return ESP_FAIL;
    }
        ...

the image it shows me is from before, it takes a delayed capture.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I want that when I ask for a capture, it gives me the one from that moment, not the one stored in the buffer

>Solution :

I have the same problem, I’ve been looking for the solution for days and although it seems to be fine, it doesn’t do what it’s supposed to do.
At the moment I am using this "trick":

fb = esp_camera_fb_get();
esp_camera_fb_return(fb);
fb = esp_camera_fb_get();

I ask for a capture, I discard it and then I ask for another one, which is current

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading