Porównaj commity

...

5 Commity

Autor SHA1 Wiadomość Data
Alan 30066279ab
Update ESP32cam-demo.ino 2023-10-17 10:25:33 +01:00
Alan 4eea351400
Update ESP32cam-demo.ino 2023-10-17 10:16:50 +01:00
Alan bc9b41b074
Add files via upload 2023-10-17 09:45:38 +01:00
Alan 0397eb201b
Update ESP32cam-demo.ino 2023-10-17 09:39:15 +01:00
Alan 5d07ac54ec
Update ESP32cam-demo.ino 2023-10-17 08:53:44 +01:00
2 zmienionych plików z 26 dodań i 19 usunięć

Wyświetl plik

@ -92,7 +92,7 @@
// ---------------------------------------------------------------
char* stitle = "ESP32Cam-demo"; // title of this sketch
char* sversion = "16oct23"; // Sketch version
char* sversion = "17oct23"; // Sketch version
#define ENABLE_OTA 0 // If OTA updating of this sketch is enabled (requires ota.h)
const String OTAPassword = "password"; // Password reuired to enable OTA (supplied as - http://<ip address>?pwd=xxxx )
@ -211,13 +211,14 @@ WebServer server(80); // serve web pages on port 80
String spiffsFilename = "/image.jpg"; // image name to use when storing in spiffs
String ImageResDetails = "Unknown"; // image resolution info
#if ENABLE_OTA
// OTA Stuff
void sendHeader(WiFiClient &client, char* hTitle); // forward declarations
void sendFooter(WiFiClient &client);
bool OTAEnabled = 0; // flag to show if OTA has been enabled (via supply of password in http://x.x.x.x/ota)
#include "ota.h" // Over The Air updates (OTA)
#endif
// OTA Stuff
bool OTAEnabled = 0; // flag to show if OTA has been enabled (via supply of password in http://x.x.x.x/ota)
#if ENABLE_OTA
void sendHeader(WiFiClient &client, char* hTitle); // forward declarations
void sendFooter(WiFiClient &client);
#include "ota.h" // Over The Air updates (OTA)
#endif
// ---------------------------------------------------------------
// -SETUP SETUP SETUP SETUP SETUP SETUP
@ -976,6 +977,9 @@ void handleRoot() {
client.write("<a href='/jpg'>JPG</a> - \n");
client.write("<a href='/jpeg'>Updating JPG</a> - \n");
client.write("<a href='/test'>Test procedure</a>\n");
#if ENABLE_OTA
client.write(" - <a href='/ota'>Update via OTA</a>\n");
#endif
// addnl info if sd card present
if (sdcardPresent) {
@ -1612,6 +1616,7 @@ void readGreyscaleImage() {
delay(camChangeDelay);
config.pixel_format = PIXFORMAT_GRAYSCALE; // change camera setting to greyscale (default is JPG)
initialiseCamera(0); // restart the camera (0 = without resetting all the other camera settings)
cameraImageSettings();
// capture the image and use flash if required
int currentBrightness = brightLEDbrightness;
@ -1629,32 +1634,34 @@ void readGreyscaleImage() {
// read image data and calculate average pixel value (as demonstration of reading the image data)
// note: image x = i % WIDTH, image y = floor(i / WIDTH)
unsigned long dataSize = fb->width * fb->height;
unsigned long avrg = 0;
byte minV=255; byte maxV=0;
for (int y=0; y < fb->height; y++) {
for (int x=0; x < fb->width; x++) {
avrg += fb->buf[(y * fb->width) + x];
byte pixelVal = fb->buf[(y * fb->width) + x];
if (pixelVal > maxV) maxV = pixelVal;
if (pixelVal < minV) minV = pixelVal;
}
}
client.println("Greyscale Image: The average brightness of the " + String(dataSize) + " pixels is " + String(avrg / dataSize));
client.println("Greyscale Image: The lowest value pixel is " + String(minV) + ", the highest is " + String(maxV));
client.write("<br><br><a href='/'>Return</a>\n"); // link back
// resize the image
int newWidth = 100; int newHeight = 36;
int newWidth = 115; int newHeight = 42; // much bigger than this seems to cause problems, probably a memory issue?
byte newBuf[newWidth * newHeight];
resize_esp32cam_image_buffer(fb->buf, fb->width, fb->height, newBuf, newWidth, newHeight);
// display image as asciiArt
char asciiArt[] = {' ','.',',',':',';','+','*','?','%','S','#','@'}; // characters to use (light to dark)
int noAsciiChars = sizeof(asciiArt) / sizeof(asciiArt[0]); // number of characters available
client.write("<br><pre>"); // 'pre' stops variable character spacing
char asciiArt[] = {'@','#','S','%','?','*','+',';',':',',','.',' '}; // characters to use
int noAsciiChars = sizeof(asciiArt) / sizeof(asciiArt[0]); // number of characters available
client.write("<br><pre style='line-height: 1.1;'>"); // 'pre' stops variable character spacing, 'line-heigh' adjusts spacing between lines - 0.2
for (int y=0; y < newHeight; y++) {
client.write("</pre><pre style='line-height: 0.2;'>"); // 'line-heigh' adjusts spacing between lines
client.write("\n"); // new line
for (int x=0; x < newWidth; x++) {
int tpos = map(newBuf[y*newWidth+x],0,255,0,noAsciiChars-1); // convert pixel brightness to ascii character
client.write(asciiArt[noAsciiChars - tpos]);
int tpos = map(newBuf[y*newWidth+x], minV, maxV, 0, noAsciiChars - 1); // convert pixel brightness to ascii character
client.write(asciiArt[tpos]);
}
}
client.write("<br></pre>");
client.write("</pre><br>");
// close web page
sendFooter(client);

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 131 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 499 KiB