ESP32 CAM : How to send good quality images via MQTT
Has anyone here ever used a ESP32 CAM to send an image via MQTT? I’d like to know what are the parameters to initialize the camera with (resolution, jpeg quality, etc.), because once I receive the camera on the other side, it’s highly compressed and to be frank really ugly.
I’m using FRAMESIZE_SVGA with jpeg quality of 12. I want the best of both worlds actually: I want a good quality image and I don’t want to overload the MQTT packet as I want to be able to receive the image faster. If resolution is high, it usually takes a few minutes to receive anything.
Here’s my camera’s config:
void initCamera()
{
// https://github.com/botabotlab/ESP32CAM-MQTT/blob/master/ESP32_Cam_MQTT/ESP32_Cam_MQTT.ino (initCamera and capturePicture)
camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = 5;
config.pin_d1 = 18;
config.pin_d2 = 19;
config.pin_d3 = 21;
config.pin_d4 = 36;
config.pin_d5 = 39;
config.pin_d6 = 34;
config.pin_d7 = 35;
config.pin_xclk = 0;
config.pin_pclk = 22;
config.pin_vsync = 25;
config.pin_href = 23;
config.pin_sscb_sda = 26;
config.pin_sscb_scl = 27;
config.pin_pwdn = 32;
config.pin_reset = -1;
config.xclk_freq_hz = 20000000;
config.pixel_format = PIXFORMAT_JPEG;
// QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA
// Change resolution of image here
config.frame_size = FRAMESIZE_SVGA;
config.jpeg_quality = 10;
config.fb_count = 1;
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
return;
}
}
Read more here: Source link