kopia lustrzana https://github.com/alanesq/esp32cam-demo
Porównaj commity
3 Commity
9cddd641b3
...
a14dc1f7dc
Autor | SHA1 | Data |
---|---|---|
Alan | a14dc1f7dc | |
Alan | 0a648339b4 | |
Alan | ed50ea7d7f |
|
@ -3,7 +3,7 @@
|
||||||
* ESP32Cam development board demo sketch using Arduino IDE or PlatformIO
|
* ESP32Cam development board demo sketch using Arduino IDE or PlatformIO
|
||||||
* Github: https://github.com/alanesq/ESP32Cam-demo
|
* Github: https://github.com/alanesq/ESP32Cam-demo
|
||||||
*
|
*
|
||||||
* Tested with ESP32 board manager version 1.0.6
|
* Tested with ESP32 board manager version 2.0.11
|
||||||
*
|
*
|
||||||
* Starting point sketch for projects using the esp32cam development board with the following features
|
* Starting point sketch for projects using the esp32cam development board with the following features
|
||||||
* web server with live video streaming and RGB data from camera demonstrated.
|
* web server with live video streaming and RGB data from camera demonstrated.
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
|
|
||||||
char* stitle = "ESP32Cam-demo"; // title of this sketch
|
char* stitle = "ESP32Cam-demo"; // title of this sketch
|
||||||
char* sversion = "27Jul23"; // Sketch version
|
char* sversion = "28Jul23"; // Sketch version
|
||||||
|
|
||||||
bool sendRGBfile = 0; // if set '/rgb' will just return raw rgb data which can be saved as a file rather than display a HTML pag
|
bool sendRGBfile = 0; // if set '/rgb' will just return raw rgb data which can be saved as a file rather than display a HTML pag
|
||||||
|
|
||||||
|
@ -255,6 +255,7 @@ void setup() {
|
||||||
server.on("/img", handleImg); // show image from sd card
|
server.on("/img", handleImg); // show image from sd card
|
||||||
server.on("/rgb", readRGBImage); // demo converting image to RGB
|
server.on("/rgb", readRGBImage); // demo converting image to RGB
|
||||||
server.on("/test", handleTest); // Testing procedure
|
server.on("/test", handleTest); // Testing procedure
|
||||||
|
server.on("/reboot", handleReboot); // restart device
|
||||||
server.onNotFound(handleNotFound); // invalid url requested
|
server.onNotFound(handleNotFound); // invalid url requested
|
||||||
|
|
||||||
// NTP - internet time
|
// NTP - internet time
|
||||||
|
@ -681,8 +682,8 @@ void changeResolution(framesize_t tRes = FRAMESIZE_96X96) {
|
||||||
delay(50);
|
delay(50);
|
||||||
if (tRes == FRAMESIZE_96X96) { // taken as none supplied so cycle through several
|
if (tRes == FRAMESIZE_96X96) { // taken as none supplied so cycle through several
|
||||||
if (FRAME_SIZE_IMAGE == FRAMESIZE_QVGA) tRes = FRAMESIZE_VGA;
|
if (FRAME_SIZE_IMAGE == FRAMESIZE_QVGA) tRes = FRAMESIZE_VGA;
|
||||||
else if (FRAME_SIZE_IMAGE == FRAMESIZE_VGA) tRes = FRAMESIZE_XGA;
|
else if (FRAME_SIZE_IMAGE == FRAMESIZE_VGA) tRes = FRAMESIZE_SVGA;
|
||||||
//else if (FRAME_SIZE_IMAGE == FRAMESIZE_XGA) tRes = FRAMESIZE_UXGA;
|
else if (FRAME_SIZE_IMAGE == FRAMESIZE_SVGA) tRes = FRAMESIZE_SXGA;
|
||||||
else tRes = FRAMESIZE_QVGA;
|
else tRes = FRAMESIZE_QVGA;
|
||||||
}
|
}
|
||||||
FRAME_SIZE_IMAGE = tRes;
|
FRAME_SIZE_IMAGE = tRes;
|
||||||
|
@ -707,9 +708,15 @@ byte storeImage() {
|
||||||
|
|
||||||
// capture the image from camera
|
// capture the image from camera
|
||||||
int currentBrightness = brightLEDbrightness;
|
int currentBrightness = brightLEDbrightness;
|
||||||
if (flashRequired) brightLed(255); // change LED brightness (0 - 255)
|
if (flashRequired) {
|
||||||
|
brightLed(255); // change LED brightness (0 - 255)
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
camera_fb_t *fb = esp_camera_fb_get(); // capture image frame from camera
|
camera_fb_t *fb = esp_camera_fb_get(); // capture image frame from camera
|
||||||
if (flashRequired) brightLed(currentBrightness); // change LED brightness back to previous state
|
if (flashRequired){
|
||||||
|
delay(100);
|
||||||
|
brightLed(currentBrightness); // change LED brightness back to previous state
|
||||||
|
}
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
if (serialDebug) Serial.println("Error: Camera capture failed");
|
if (serialDebug) Serial.println("Error: Camera capture failed");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1523,14 +1530,14 @@ int requestWebPage(String* page, String* received, int maxWaitTime=5000){
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
// -show updating image i.e. http://x.x.x.x/jpeg
|
// -show refreshing image i.e. http://x.x.x.x/jpeg
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
|
|
||||||
void handleJpeg() {
|
void handleJpeg() {
|
||||||
|
|
||||||
int refreshRate = 2000; // image refresh rate (ms)
|
const int refreshRate = 2000; // image refresh rate (ms)
|
||||||
|
|
||||||
WiFiClient client = server.client(); // open link with client
|
WiFiClient client = server.client(); // open link with client
|
||||||
|
|
||||||
// Start page
|
// Start page
|
||||||
client.write("HTTP/1.1 200 OK\r\n");
|
client.write("HTTP/1.1 200 OK\r\n");
|
||||||
|
@ -1659,5 +1666,23 @@ void handleTest() {
|
||||||
} // handleTest
|
} // handleTest
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
// -reboot web page requested i.e. http://x.x.x.x/reboot
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
// note: this can fail if the esp has just been reflashed and not restarted
|
||||||
|
|
||||||
|
void handleReboot(){
|
||||||
|
|
||||||
|
String message = "Rebooting....";
|
||||||
|
server.send(200, "text/plain", message); // send reply as plain text
|
||||||
|
|
||||||
|
// rebooting
|
||||||
|
delay(500); // give time to send the above html
|
||||||
|
ESP.restart();
|
||||||
|
delay(5000); // restart fails without this delay
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ******************************************************************************************************************
|
// ******************************************************************************************************************
|
||||||
// end
|
// end
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
NOTE: When using Arduino IDE I find it reboots if no sd card present and the LED stays on full all the time with latest esp32 board manager. I am using version 1.0.6
|
NOTE: When using Arduino IDE I find it reboots if no sd card present and the LED stays on full all the time with latest esp32 board manager. I am using version 1.0.6
|
||||||
known bug: https://github.com/espressif/arduino-esp32/issues/5195
|
known bug: https://github.com/espressif/arduino-esp32/issues/5195
|
||||||
|
|
||||||
|
I seem to have having trouble with XGA with more recent versions (i.e. 1024x768)
|
||||||
|
|
||||||
## ESP32Cam-demo sketch for use with the Arduino IDE or PlatformIO
|
## ESP32Cam-demo sketch for use with the Arduino IDE or PlatformIO
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue