fustyles / Arduino

389 stars 287 forks source link

Higher Resolutions Gives Partial Photo w/ ESP32-CAM-Gmail #8

Open iannecj opened 3 years ago

iannecj commented 3 years ago

Hi! First I wanted to thankyou for this excellent repo. Your work has given me such a jump start!

I am mostly successfully using this project to email photos from esp32cam to gmail. Using an AI THINKER and configuring IDE WROVER and for Huge App.

My goal is to up resolution to UXGA but it seems anything larger than XGA or so yields an incomplete photo .

### Here is the line I change but I wonder if there is more to change to accomplish this goal?

//drop down frame size for higher initial frame rate sensor_t * s = esp_camera_sensor_get(); s->set_framesize(s, FRAMESIZE_SXGA); // UXGA|SXGA|XGA|SVGA|VGA|CIF|QVGA|HQVGA|QQVGA

https://mail.google.com/mail/u/0?ui=2&ik=f67ad2587b&attid=0.1&permmsgid=msg-f:1692042977312598260&th=177b581f7f6968f4&view=att&disp=safe

FBMinis commented 3 years ago

In my experience, we need to lower the quality for anything above VGA. The highest I could get was SXGA but every so often a photo would show up incomplete. I believe this has to do with the timings involved in capturing a frame and how long the communication with the server is.

Try: config.jpeg_quality = 20; //0-63 lower number means higher quality

Also, I have read that anything you do after sensor_t * s = esp_camera_sensor_get(); needs some time to take effect, so I added a delay before fb = esp_camera_fb_get(); which improved the quality of the exposure (I was getting dark photos before this).

I have tried sending photos to telegram, saving to google drive, sending to gmail, etc, using Universal Telegram Bot, Random Nerds Tutorials and fustyles sketches/libraries. I found that it is easy to make the ESP32-CAM work but making it work well in real life conditions is a balancing act, we need to put some effort into it.

As an example, try this timelapse sketch, which is a significant improvement over using the trivial routines. It took the author some deep diving into setting registers but the picture quality is much better even in very low light conditions:

https://github.com/raduprv/esp32-cam_ov2640-timelapse

iannecj commented 3 years ago

Great appreciate you work and your suggestions. Thank you, Chris

On Sat, Feb 27, 2021 at 10:18 AM FBMinis notifications@github.com wrote:

In my experience, we need to lower the quality for anything above VGA. The highest I could get was SXGA but every so often a photo would show up incomplete. I believe this has to do with the timings involved in capturing a frame and how long the communication with the server is.

Try: config.jpeg_quality = 20; //0-63 lower number means higher quality

Also, I have read that anything you do after sensor_t * s = esp_camera_sensor_get(); needs some time to take effect, so I added a delay before fb = esp_camera_fb_get(); which improved the quality of the exposure (I was getting dark photos before this).

I have tried sending photos to telegram, saving to google drive, sending to gmail, etc, using Universal Telegram Bot, Random Nerds Tutorials and fustyles sketches/libraries. I found that it is easy to make the ESP32-CAM work but making it work well in real life conditions is a balancing act, we need to put some effort into it.

As an example, try this timelapse sketch, which is a significant improvement over using the trivial routines. It took the author some deep diving into setting registers but the picture quality is much better even in very low light conditions:

https://github.com/raduprv/esp32-cam_ov2640-timelapse

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fustyles/Arduino/issues/8#issuecomment-787088648, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM3QU5Y4AG7VFHCWRNF3IW3TBEEKZANCNFSM4X2MSPCA .

chupocro commented 3 years ago

In my experience, we need to lower the quality for anything above VGA. The highest I could get was SXGA but every so often a photo would show up incomplete. I believe this has to do with the timings involved in capturing a frame and how long the communication with the server is.

I don't think it has to do something with capturing because with CameraWebServer UXGA (1600x1200) at quality = 10 every image works 100%

The problem is uploading to Google Drive because there isn't enough RAM for storing both the original framebuffer with the captured picture and base64 + URL encoded .jpg file.

In other words:

"Content-Type: image/jpeg"
...
client.write(fbBuf, 1024);

works but:

"data:image/jpeg;base64,"
...
"Content-Type: application/x-www-form-urlencoded"
...
client_tcp.print(imageFile.substring(Index, Index+1000));

doesn't because there isn't enough PSRAM.

Maybe it would be possible to first encode and send the first half of the data and then to encode and send the second half of the data. I don't know if Google App Script could be modified to work with "Content-Type: image/jpeg". Maybe there is some file sharing service (Mega? Dropbox?) that could accept the image sent in the same way CameraWebServer is sending the images.