kopia lustrzana https://github.com/alanesq/esp32cam-demo
Add files via upload
rodzic
0f866e83de
commit
6418874f30
|
@ -661,8 +661,10 @@ void handleNotFound() {
|
||||||
// note: I do not know how high resolution you can go and not run out of memory
|
// note: I do not know how high resolution you can go and not run out of memory
|
||||||
|
|
||||||
void readRGBImage() {
|
void readRGBImage() {
|
||||||
Serial.println("Reading camera image as RGB");
|
|
||||||
String tHTML = "LIVE IMAGE AS RGB DATA: "; // reply to send to web client
|
uint32_t resultsToShow = 40; // how much data to display
|
||||||
|
|
||||||
|
String tReply = "LIVE IMAGE AS RGB DATA: "; // reply to send to web client and serial port
|
||||||
|
|
||||||
// capture live image (jpg)
|
// capture live image (jpg)
|
||||||
camera_fb_t * fb = NULL;
|
camera_fb_t * fb = NULL;
|
||||||
|
@ -670,7 +672,7 @@ void readRGBImage() {
|
||||||
|
|
||||||
// allocate memory to store rgb data
|
// allocate memory to store rgb data
|
||||||
void *ptrVal = NULL;
|
void *ptrVal = NULL;
|
||||||
int ARRAY_LENGTH = I_WIDTH * I_HEIGHT * 3; // pixels in the image image x 3
|
uint32_t ARRAY_LENGTH = I_WIDTH * I_HEIGHT * 3; // pixels in the image image x 3
|
||||||
ptrVal = heap_caps_malloc(ARRAY_LENGTH, MALLOC_CAP_SPIRAM);
|
ptrVal = heap_caps_malloc(ARRAY_LENGTH, MALLOC_CAP_SPIRAM);
|
||||||
uint8_t *rgb = (uint8_t *)ptrVal;
|
uint8_t *rgb = (uint8_t *)ptrVal;
|
||||||
|
|
||||||
|
@ -678,28 +680,22 @@ void readRGBImage() {
|
||||||
fmt2rgb888(fb->buf, fb->len, PIXFORMAT_JPEG, rgb);
|
fmt2rgb888(fb->buf, fb->len, PIXFORMAT_JPEG, rgb);
|
||||||
|
|
||||||
// display some of the result
|
// display some of the result
|
||||||
int resultsToShow = 40; // how much data to display
|
|
||||||
String tOut;
|
|
||||||
Serial.println("RGB data: ");
|
|
||||||
for (uint32_t i = 0; i < resultsToShow; i++) {
|
for (uint32_t i = 0; i < resultsToShow; i++) {
|
||||||
// const uint16_t x = i % I_WIDTH;
|
// // x and y coordinate of the pixel
|
||||||
// const uint16_t y = floor(i / I_WIDTH);
|
// uint16_t x = i % I_WIDTH;
|
||||||
tOut = "";
|
// uint16_t y = floor(i / I_WIDTH);
|
||||||
if (i%3 == 0) tOut="R";
|
if (i%3 == 0) tReply+=",B";
|
||||||
if (i%3 == 1) tOut="G";
|
else if (i%3 == 1) tReply+=",G";
|
||||||
if (i%3 == 2) tOut="B";
|
else if (i%3 == 2) tReply+=",R";
|
||||||
tOut+= String(rgb[i]);
|
tReply+= String(rgb[i]);
|
||||||
tOut+=",";
|
|
||||||
Serial.print(tOut);
|
|
||||||
tHTML+=tOut;
|
|
||||||
}
|
}
|
||||||
Serial.println();
|
|
||||||
|
|
||||||
// free up memory
|
// free up memory
|
||||||
esp_camera_fb_return(fb);
|
esp_camera_fb_return(fb);
|
||||||
heap_caps_free(ptrVal);
|
heap_caps_free(ptrVal);
|
||||||
|
|
||||||
server.send ( 404, "text/plain", tHTML );
|
Serial.println(tReply);
|
||||||
|
server.send ( 404, "text/plain", tReply);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue