Esp32 camera ov2640 jpeg format

I'm experiencing an issue with my OV2640 camera, which supposedly supports four image formats: RGB565, YUV422, grayscale, and JPEG. All formats work correctly except for JPEG, which is the one I need the most. Interestingly, JPEG was working fine initially, but then suddenly stopped functioning, even though I haven't made any significant changes to the code. The camera initialization process works without any issues, so I'm unsure what could be causing this problem. Has anyone encountered a similar situation and could offer some advice?
Here is my initialization function:

bool Camera::initCamera()
{
  pinMode(VCC_CAM_EN, OUTPUT);
  digitalWrite(VCC_CAM_EN, HIGH); // Power on the camera
  delay(1000);                    // Delay to ensure the camera module is powered up
  camera_config_t config;
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = PIN_D0;
  config.pin_d1 = PIN_D1;
  config.pin_d2 = PIN_D2;
  config.pin_d3 = PIN_D3;
  config.pin_d4 = PIN_D4;
  config.pin_d5 = PIN_D5;
  config.pin_d6 = PIN_D6;
  config.pin_d7 = PIN_D7;
  config.pin_xclk = PIN_XCLK;
  config.pin_pclk = PIN_PCLK;
  config.pin_vsync = PIN_VSYNC;
  config.pin_href = PIN_HREF;
  config.pin_sccb_sda = PIN_SDA;
  config.pin_sccb_scl = PIN_SCL;
  config.pin_pwdn = PIN_PWDN;
  config.pin_reset = PIN_RESET;
  config.xclk_freq_hz = 20000000;
  config.pixel_format = PIXFORMAT_JPEG;
  config.frame_size = FRAMESIZE_QVGA;
  config.jpeg_quality = 12; // Set JPEG quality
  config.fb_count = 1;

  if (psramFound())
  {
    config.fb_location = CAMERA_FB_IN_PSRAM;
  }
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK)
  {
    // Serial.printownf("Camera init failed with error 0x%x", err);
    payload->initCamera = 1;
    return false;
  }
    sensor_t *s = esp_camera_sensor_get();
    if (!s) {
        printf("Camera sensor get failed");
        return false;
    }

    // Utwórz strukturę sensor_id_t
    sensor_id_t id;
    id.MIDH = s->id.MIDH;
    id.MIDL = s->id.MIDL;
    id.PID = s->id.PID;
    id.VER = s->id.VER;

    camera_sensor_info_t *info = esp_camera_sensor_get_info(&id);
    if (info == nullptr) {
        printf("Failed to get sensor info");
        return false;
    }

 
    if (info->support_jpeg) {
        printf("Sensor %s supports JPEG format.\n", info->name);
    } else {
        printf("Sensor %s does not support JPEG format.\n", info->name);
    }
  payload->initCamera = 0;
  return true;
}

Your topic has been moved. Please do not post in "Uncategorized"; see the sticky topics in Uncategorized - Arduino Forum.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.