alanesq / esp32cam-demo

esp32cam module demo / shows how you can easily use the esp32cam including reading raw rgb data, streaming, displaying the image etc.(ArduinoIDE or PlatformIO)
GNU General Public License v3.0
110 stars 18 forks source link

Error: failed to capture image #8

Open FBMinis opened 1 year ago

FBMinis commented 1 year ago

When I try to capture a jpeg or a stream, I get this error message Error: failed to capture image

I'm using an AI-Thinker board (the chip has the Espressif logo); Arduino 1.8.19 with ESP32 core 2.0.13

I tried with another OV2640 lens with the same result. If I removed the lens, I can runs the example sketches in Arduino, like WifiScan, Test LittleFS, Deepsleep, GpioInterrupt, etc.

10:24:28.980 -> ----------------------------------- 10:24:28.980 -> Starting - ESP32Cam-demo - 25oct23 10:24:28.980 -> ----------------------------------- 10:24:28.980 -> 10:24:28.980 -> Connecting to Reis 10:24:28.980 -> [ 495][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 0 - WIFI_READY 10:24:29.108 -> [ 583][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 2 - STA_START 10:24:29.143 -> [ 641][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 4 - STA_CONNECTED 10:24:29.178 -> [ 662][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 7 - STA_GOT_IP 10:24:29.178 -> [ 662][D][WiFiGeneric.cpp:991] _eventCallback(): STA IP: 192.168.1.90, MASK: 255.255.255.0, GW: 192.168.1.254 10:24:29.580 -> . 10:24:29.580 -> WiFi connected, IP address: 192.168.1.90 10:24:29.580 -> 10:24:29.580 -> Getting real time (NTP) 10:24:29.580 -> .......................now 1698747870 10:24:31.885 -> Tue 31-10-23 10:24:30 10:24:31.885 -> 10:24:31.885 -> 10:24:31.885 -> Initialising camera: Applying camera settings 10:24:32.119 -> OK 10:24:37.229 -> SPIFFS mounted successfully: total bytes: 896321 , used: 0 10:24:37.276 -> E (8728) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107 10:24:37.276 -> E (8729) vfs_fat_sdmmc: sdmmc_card_init failed (0x107). 10:24:37.276 -> [ 8732][E][SD_MMC.cpp:138] begin(): Failed to initialize the card (0x107). Make sure SD card lines have pull-up resistors in place. 10:24:37.276 -> No SD Card detected 10:24:37.276 -> Brightness changed to 0 10:24:37.276 -> 10:24:37.276 -> Started... 10:24:40.276 -> Brightness changed to 64 10:24:40.510 -> Brightness changed to 0 10:24:40.510 -> [ 11954][I][WiFiClient.cpp:548] connected(): Unexpected: RES: 0, ERR: 88 10:24:40.510 -> [ 11955][I][WiFiClient.cpp:548] connected(): Unexpected: RES: 0, ERR: 88 10:24:40.510 -> [ 11966][I][WiFiClient.cpp:548] connected(): Unexpected: RES: 0, ERR: 88 10:24:40.510 -> [ 11966][I][WiFiClient.cpp:548] connected(): Unexpected: RES: 0, ERR: 88 10:24:40.510 -> [ 11977][I][WiFiClient.cpp:548] connected(): Unexpected: RES: 0, ERR: 88 10:24:40.510 -> [ 11978][I][WiFiClient.cpp:548] connected(): Unexpected: RES: 0, ERR: 88 10:24:40.510 -> [ 11990][I][WiFiClient.cpp:548] connected(): Unexpected: RES: 0, ERR: 88 10:24:40.510 -> [ 11990][I][WiFiClient.cpp:548] connected(): Unexpected: RES: 0, ERR: 88 10:24:52.262 -> .now 1698747891 10:24:52.394 -> Tue 31-10-23 10:24:51 10:24:52.394 -> 10:27:08.733 -> E (160247) gpio: gpio_install_isr_service(449): GPIO isr service already installed 10:27:08.935 -> Applying camera settings 10:27:08.981 -> Applying camera settings 10:27:09.473 -> cam_hal: EV-EOF-OVF 10:27:09.757 -> cam_hal: EV-EOF-OVF 10:27:09.957 -> cam_hal: EV-EOF-OVF 10:27:10.473 -> cam_hal: EV-EOF-OVF 10:27:10.791 -> cam_hal: EV-EOF-OVF 10:27:11.090 -> cam_hal: EV-EOF-OVF 10:27:11.288 -> cam_hal: EV-EOF-OVF 10:27:11.590 -> cam_hal: EV-EOF-OVF 10:27:12.021 -> cam_hal: EV-EOF-OVF 10:27:12.321 -> cam_hal: EV-EOF-OVF 10:27:12.552 -> cam_hal: EV-EOF-OVF 10:27:12.940 -> cam_hal: EV-EOF-OVF 10:27:13.222 -> cam_hal: EV-EOF-OVF 10:27:13.638 -> cam_hal: EV-EOF-OVF 10:27:14.073 -> cam_hal: EV-VSYNC-OVF 10:27:14.555 -> cam_hal: EV-EOF-OVF 10:27:14.790 -> cam_hal: EV-EOF-OVF 10:27:15.289 -> cam_hal: EV-EOF-OVF 10:27:15.505 -> cam_hal: EV-EOF-OVF 10:27:15.806 -> cam_hal: EV-EOF-OVF 10:27:16.124 -> cam_hal: EV-EOF-OVF 10:27:30.766 -> E (182259) gpio: gpio_install_isr_service(449): GPIO isr service already installed 10:27:30.984 -> Applying camera settings 10:27:31.394 -> [182895][E][WebServer.cpp:647] _handleRequest(): request handler not found 10:27:31.394 -> Invalid page requested.now 1698748112 10:28:33.746 -> Tue 31-10-23 10:28:32 10:28:33.746 -> 10:28:42.254 -> Error: failed to capture image 10:28:50.251 -> Error: failed to capture image 10:28:58.254 -> Error: failed to capture image 10:29:06.251 -> Error: failed to capture image 10:29:14.275 -> Error: failed to capture image

greyscale as data

photo_1_2023-10-31_10-59-53 photo_2_2023-10-31_10-59-53 photo_3_2023-10-31_10-59-53

alanesq commented 1 year ago

Hi, Have you tried using a lower resolution image? e.g. I have recently experienced a lot of issues when using 1024x768 also, it is always worth trying a different power supply as I have had all sorts of strange issues when it doesn't like the power. I always put a large capacitor across the power feed to any esp32 to try and prevent this.

FBMinis commented 1 year ago

Yes, I even tried QVGA, connecting the camera to a phone charger, 3xAA alkalines, etc

The camera was kept in its sealed bag until yesterday, bought in May from TZT store on Aliexpress.

Would you recommend any tests to debug what's happening around the time camera_fb_t * fb = esp_camera_fb_get();

I wonder what it's trying to access but can't get through.

Thank you in advance for your time.

alanesq commented 1 year ago

Hi, I just realised that I am on an out of date version of the ESP32 core (I was on 2.0.11) and I have just updated to 2.0.14 and much to my surprise it still works ok (I usually expect problems when there is an update ;-) I have just uploaded the latest version of my sketch just in case there is something wrong with the latest one I have uploaded. BTW - I am assuming you have the "AI thinker esp32cam" board selected in your Arduino IDE? Not sure what else to suggest, I have lots of these esp32cam boards from many suppliers but I have not had this issue myself (I have had the odd camera module fail but you have tried another one in yours).

Adnl: I recently discovered that there seems to be a bug in which when you capture a jpg it just gives you data from a previous frame so I added the below lines to get round this by dropping the first frame and grabbing a second. It might be worth trying deleting them in your sketch in case this is causing your problem?

    // there is a bug where this buffer can be from previous capture so as workaround it is discarded and captured again
      esp_camera_fb_return(fb); // dispose the buffered image
      fb = NULL; // reset to capture errors
      fb = esp_camera_fb_get(); // get fresh image
FBMinis commented 1 year ago

I'm very intrigued as to why the board works without the OV2640 module and also with why the module communicates with the board but it cant retrieve an fb.

I opened an issue here: https://github.com/espressif/esp32-camera/issues/592

FBMinis commented 1 year ago

I found more people complaining about this problem. It's bad hardware:

https://github.com/espressif/esp32-camera/issues/43?spm=a2g0s.imconversation.0.0.7ffc3e5fxwkLbB#issuecomment-635591135

Boards with Espressif logo instead of AI-Thinker and lens modules with OV2640 written on the ribbon cable present this problem.

epietrowicz commented 11 months ago

Hey I had this same problem, but was unintentionally using GPIO0 for a button interrupt. Apparently the camera module uses GPIO0 as a clock pin. Changing my button interrupt to a different pin solved this issue for me.