Closed garvitkhera closed 6 months ago
push, have you solved it ?
Hi @bulior
Adding a slight delay after sensor_t *s = esp_camera_sensor_get();
solved the issue. I guess the sensor takes a little time to grab the current settings and then apply new ones.
Thanks @garvitkhera for your fast reply, but i will get the following error: E (10027) camera: Camera probe failed with error 0x105(ESP_ERR_NOT_FOUND)
Can you share your complete code ? Thanks ;)
My Code:
` // ===========================
// =========================== // Enter your WiFi credentials // =========================== const char ssid = "XXX"; const char password = "XXX";
void startCameraServer(); void setupLedFlash(int pin);
OV5640 ov5640 = OV5640();
void setup() { Serial.begin(115200); while(!Serial); Serial.setDebugOutput(true); Serial.println();
camera_config_t config; config.ledc_channel = LEDC_CHANNEL_0; config.ledc_timer = LEDC_TIMER_0; config.pin_d0 = Y2_GPIO_NUM; config.pin_d1 = Y3_GPIO_NUM; config.pin_d2 = Y4_GPIO_NUM; config.pin_d3 = Y5_GPIO_NUM; config.pin_d4 = Y6_GPIO_NUM; config.pin_d5 = Y7_GPIO_NUM; config.pin_d6 = Y8_GPIO_NUM; config.pin_d7 = Y9_GPIO_NUM; config.pin_xclk = XCLK_GPIO_NUM; config.pin_pclk = PCLK_GPIO_NUM; config.pin_vsync = VSYNC_GPIO_NUM; config.pin_href = HREF_GPIO_NUM; config.pin_sscb_sda = SIOD_GPIO_NUM; config.pin_sscb_scl = SIOC_GPIO_NUM; config.pin_pwdn = PWDN_GPIO_NUM; config.pin_reset = RESET_GPIO_NUM; config.xclk_freq_hz = 20000000; config.pixel_format = PIXFORMAT_JPEG; config.frame_size = FRAMESIZE_VGA; config.jpeg_quality = 10; config.fb_count = 2;
// if PSRAM IC present, init with UXGA resolution and higher JPEG quality // for larger pre-allocated frame buffer. if(config.pixel_format == PIXFORMAT_JPEG){ if(psramFound()){ config.jpeg_quality = 10; config.fb_count = 2; config.grab_mode = CAMERA_GRAB_LATEST; } else { // Limit the frame size when PSRAM is not available config.frame_size = FRAMESIZE_SVGA; config.fb_location = CAMERA_FB_IN_DRAM; } } else { // Best option for face detection/recognition config.frame_size = FRAMESIZE_240X240;
config.fb_count = 2;
}
// camera init esp_err_t err = esp_camera_init(&config); delay(1000); if (err != ESP_OK) { Serial.printf("Camera init failed with error 0x%x", err); return; }
sensor_t* sensor = esp_camera_sensor_get(); delay(1000); ov5640.start(sensor);
if (ov5640.focusInit() == 0) { Serial.println("OV5640_Focus_Init Successful!"); }
if (ov5640.autoFocusMode() == 0) { Serial.println("OV5640_Auto_Focus Successful!"); }
// Setup LED FLash if LED pin is defined in camera_pins.h
setupLedFlash(LED_GPIO_NUM);
WiFi.begin(ssid, password); WiFi.setSleep(false);
while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected");
startCameraServer();
Serial.print("Camera Ready! Use 'http://"); Serial.print(WiFi.localIP()); Serial.println("' to connect"); }
void loop() { // Do nothing. Everything is done in another task by the web server delay(10000); }`
The error you're getting is not related to the error that I had. You can refer to this instead: #450
The effect is very poor, why? Does anyone have a solution? cat eye pattern behind door what happened
OV5640
camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM;
config.pin_pclk = PCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM;
config.pin_sccb_sda = SIOD_GPIO_NUM;
config.pin_sccb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.frame_size = FRAMESIZE_SVGA; // UXGA|SXGA|XGA|SVGA|VGA|CIF|QVGA|HQVGA|QQVGA
config.pixel_format = PIXFORMAT_JPEG; // for streaming
// config.pixel_format = PIXFORMAT_RGB565; // for face detection/recognition
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
config.fb_location = CAMERA_FB_IN_PSRAM;
config.jpeg_quality = 10;// 0-63 lower number means higher quality
config.fb_count = 1;
// if PSRAM IC present, init with UXGA resolution and higher JPEG quality
// for larger pre-allocated frame buffer.
if(config.pixel_format == PIXFORMAT_JPEG){
if(psramFound()){
config.jpeg_quality = 10; // Lower value for higher quality
config.fb_count = 3; // Increase frame buffer count
config.grab_mode = CAMERA_GRAB_LATEST; // Change grab mode
} else {
// Increase the frame size when PSRAM is not available
config.frame_size = FRAMESIZE_UXGA; // Higher resolution
config.fb_location = CAMERA_FB_IN_DRAM;
}
} else {
// Best option for face detection/recognition
config.frame_size = FRAMESIZE_240X240;
#if CONFIG_IDF_TARGET_ESP32S3
config.fb_count = 2;
#endif
}
#if defined(CAMERA_MODEL_ESP_EYE)
pinMode(13, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
#endif
// camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
return;
}
sensor_t * s = esp_camera_sensor_get();
s->set_brightness(s, 1); // Increase brightness
s->set_contrast(s, 1); // Increase contrast
s->set_saturation(s, 1); // Increase saturation
s->set_special_effect(s, 0); // No special effect
s->set_whitebal(s, 1); // Enable white balance
s->set_awb_gain(s, 1); // Enable auto white balance gain
s->set_wb_mode(s, 0); // Set white balance mode to auto
s->set_exposure_ctrl(s, 1); // Enable exposure control
s->set_aec2(s, 0); // Disable automatic exposure control 2
s->set_ae_level(s, 2); // Increase auto exposure level
s->set_aec_value(s, 803); // Increase automatic exposure control value
s->set_gain_ctrl(s, 1); // Enable gain control
s->set_agc_gain(s, 6); // Increase automatic gain control level
s->set_gainceiling(s, (gainceiling_t)6); // Set gain ceiling to maximum
s->set_bpc(s, 1); // Enable black pixel cancellation
s->set_wpc(s, 1); // Enable white pixel cancellation
s->set_raw_gma(s, 1); // Enable raw gamma
s->set_lenc(s, 1); // Enable lens correction
s->set_hmirror(s, 0); // Disable horizontal mirror
s->set_vflip(s, 0); // Disable vertical flip
s->set_dcw(s, 1); // Enable downsize capture window
s->set_colorbar(s, 0); // Disable color bar
// If the sensor is OV5640, adjust the settings for this specific model
if (s->id.PID == OV5640_PID) {
s->set_vflip(s, 1); // flip it back
s->set_brightness(s, 1); // up the brightness just a bit
s->set_saturation(s, -2); // lower the saturation
}
// If the pixel format is JPEG, set the frame size to QVGA
// drop down frame size for higher initial frame rate
if (config.pixel_format == PIXFORMAT_JPEG) {
s->set_framesize(s, FRAMESIZE_SVGA);
}
#if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM)
s->set_vflip(s, 1);
s->set_hmirror(s, 1);
#endif
#if defined(CAMERA_MODEL_ESP32S3_EYE)
s->set_vflip(s, 1);
#endif
Hey @me-no-dev
I hope you are doing well.
I am writing this post to ask for your help with an issue I'm having with OV5640 sensor settings.
I use a custom board with an ESP32-S3 chip connected to an OV5640 sensor. I'm using Platformio and trying to update the sensor settings like brightness, vFlip, and hMirror as usual:
Even when using settings like this, nothing changes the image quality.
I am trying to figure out what is causing this.
Below is my platformio.ini
If you can suggest anything, I'd be grateful.
Thanks!