luc-github / ESP3D

FW for ESP8266/ESP8285/ESP32 used with 3D printer
GNU General Public License v3.0
1.78k stars 465 forks source link

Support for image capture on ESP32-CAM modules #786

Closed jackmax closed 2 years ago

jackmax commented 2 years ago

I added code to allow ESP32-CAM modules to capture images and send them over the network. One step closer to having the same functionality as Octoprint, but for a fraction of the price ;)

Code is adapted from Espressif's example web server. Fits in 1227566 bytes of Flash, even though I use a separate web server for streaming images. I also added a new endpoint to the default web server to get and set camera parameters.

The camera.html file is also adapted from the example, it could use some cleanup, optimization and styling to fit with the rest of interface. I'm not good with web development though, so maybe I'll leave it to someone else.

To allow /camera.html to be displayed in the iframe, I modified index.html and changed t.indexOf("rtp://")&&(e="http://"+e) to t.indexOf("rtp://")&&(!(t.startsWith("/")))&&(e="http://"+e)

Below is a screenshot of the new firmware in action: Screenshot 2022-07-16 at 23-35-00 EspPrinter

luc-github commented 2 years ago

the feature is already in ESP3D V3 and webui V3 did you tested it ?

camera

https://github.com/luc-github/ESP3D/tree/3.0 https://github.com/luc-github/ESP3D-WEBUI/tree/3.0

you can also save on ESP32 SD card now https://github.com/luc-github/ESP3D/issues/778

jackmax commented 2 years ago

I tested it now.

I guess it's good enough so I'll close this PR.

luc-github commented 2 years ago

About configurations / compilations I did this to avoid such issues : https://github.com/luc-github/ESP3D-Configurator which is live here: https://luc-github.github.io/

The CAMERA_MODEL_TTGO_T_JOURNAL should not be in pins list , the define is even not it list so it is set 0 - I forget to remove it - thank you for pointing this out, I have removed it

The led flash is disabled on ESP32Cam because it conflict with SD Card per my tests, but you can override the setting by controling pin directly with a macro

The camera settings can be added by macro because they do not need to be in main page, because you do not change them all the time, this is not an outside camera, also if you want bigger output of camera you can put the camera output in full page instead of panel, so you will have dedicated page for camera

about features there is a file already : https://github.com/luc-github/ESP3D/blob/3.0/Features.md