I'm using a version of the M5TimerX and code similar to what you show here.
Unfortunately my image is always slightly out of focus as shown below.
Are there any parameters to set to clean this up? I've tried theimage quality and the frame_size but nothing works.
setup camera
//! config of camera
camera_config_t _cameraConfig;
//! setup
void setup_CameraModule()
{
//! config of camera
// camera_config_t cameraConfig;
//disable brownout detector
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
_cameraConfig.ledc_channel = LEDC_CHANNEL_0;
_cameraConfig.ledc_timer = LEDC_TIMER_0;
_cameraConfig.pin_d0 = Y2_GPIO_NUM;
_cameraConfig.pin_d1 = Y3_GPIO_NUM;
_cameraConfig.pin_d2 = Y4_GPIO_NUM;
_cameraConfig.pin_d3 = Y5_GPIO_NUM;
_cameraConfig.pin_d4 = Y6_GPIO_NUM;
_cameraConfig.pin_d5 = Y7_GPIO_NUM;
_cameraConfig.pin_d6 = Y8_GPIO_NUM;
_cameraConfig.pin_d7 = Y9_GPIO_NUM;
_cameraConfig.pin_xclk = XCLK_GPIO_NUM;
_cameraConfig.pin_pclk = PCLK_GPIO_NUM;
_cameraConfig.pin_vsync = VSYNC_GPIO_NUM;
_cameraConfig.pin_href = HREF_GPIO_NUM;
_cameraConfig.pin_sscb_sda = SIOD_GPIO_NUM;
_cameraConfig.pin_sscb_scl = SIOC_GPIO_NUM;
_cameraConfig.pin_pwdn = PWDN_GPIO_NUM;
_cameraConfig.pin_reset = RESET_GPIO_NUM;
_cameraConfig.xclk_freq_hz = 20000000;
_cameraConfig.pixel_format = PIXFORMAT_JPEG; //YUV422,GRAYSCALE,RGB565,JPEG
if(psramFound())
{
SerialTemp.println("psramFound");
_cameraConfig.frame_size = FRAMESIZE_UXGA; // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA
//QQVGA-UXGA Do not use sizes above QVGA when not JPEG
_cameraConfig.jpeg_quality = 5; //0-63 lower number means higher quality
_cameraConfig.fb_count = 2; //if more than one, i2s runs in continuous mode. Use only with JPEG
}
else
{
SerialTemp.println("psram NOT Found");
_cameraConfig.frame_size = FRAMESIZE_SVGA;
_cameraConfig.jpeg_quality = 12;
_cameraConfig.fb_count = 1;
}
// Init Camera
esp_err_t err = esp_camera_init(&_cameraConfig);
if (err != ESP_OK)
{
SerialError.printf("Camera init failed with error 0x%x", err);
return;
}
SerialTemp.println("*** Camera Initialized ****");
//!try initializing each time..
initCameraSensor();
}
Init Camera Setting
void initCameraSensor()
{
sensor_t *s = esp_camera_sensor_get();
//! initial sensors are flipped vertically and colors are a bit saturated
s->set_vflip(s, 1); // flip it back
s->set_brightness(s, 1); // up the blightness just a bit
s->set_saturation(s, -2); // lower the saturation
s->set_hmirror(s, 0); //?? horizontal mirror?
// drop down frame size for higher initial frame rate
// s->set_framesize(s, FRAMESIZE_QVGA);
s->set_framesize(s, FRAMESIZE_UXGA);
SerialTemp.println("*** Camera Sensor Initialized ****");
}
Taking the picture
//!@see https://github.com/m5stack/M5Stack-Camera
//!take a picture
void takePicture_CameraModule_internal(boolean publishBinary)
{
//!try initializing each time..
// initCameraSensor();
//!turn on light
digitalWrite(2, HIGH);
//! cameras frame buffer
camera_fb_t *cameraFB = NULL;
//! Take Picture with Camera
cameraFB = esp_camera_fb_get();
if(!cameraFB)
{
SerialError.println("Camera capture failed");
return;
}
//we could use our EPROM for the next file name..
#ifdef M5_CAPTURE_SCREEN
//for now save in SPIFF
writeFB_SPIFFModule(cameraFB->buf, /*!< Pointer to the pixel data */
cameraFB->len, /*!< Length of the buffer in bytes */
(char*)"/CameraPicture.jpg");
#endif
if (publishBinary)
//! my internal writing to a web page then letting others know the URL
publishBinaryFile((char*)"usersP/bark/images", cameraFB->buf, cameraFB->len);
//!close it up
esp_camera_fb_return(cameraFB);
//!turn off light
digitalWrite(2, LOW);
}
I'm using a version of the
M5TimerX
and code similar to what you show here.Unfortunately my image is always slightly out of focus as shown below.
Are there any parameters to set to clean this up? I've tried the
image quality
and theframe_size
but nothing works.setup camera
Init Camera Setting
Taking the picture