diff --git a/PlatformIO/esp32-cam-rtos-pio/platformio.ini b/PlatformIO/esp32-cam-rtos-pio/platformio.ini index 0d2f8d5..209ae43 100644 --- a/PlatformIO/esp32-cam-rtos-pio/platformio.ini +++ b/PlatformIO/esp32-cam-rtos-pio/platformio.ini @@ -75,7 +75,7 @@ build_flags = ${env.build_flags} -D CAMERA_MODEL_AI_THINKER - -D FRAME_SIZE=FRAMESIZE_HVGA + -D FRAME_SIZE=FRAMESIZE_VGA -D FPS=10 -D WSINTERVAL=100 -D MAX_CLIENTS=10 @@ -107,7 +107,7 @@ build_flags = ${env.build_flags} -D CAMERA_MODEL_AI_THINKER - -D FRAME_SIZE=FRAMESIZE_HVGA + -D FRAME_SIZE=FRAMESIZE_VGA -D FPS=10 -D WSINTERVAL=100 -D MAX_CLIENTS=10 diff --git a/PlatformIO/esp32-cam-rtos-pio/src/main.cpp b/PlatformIO/esp32-cam-rtos-pio/src/main.cpp index 6209077..77c0647 100644 --- a/PlatformIO/esp32-cam-rtos-pio/src/main.cpp +++ b/PlatformIO/esp32-cam-rtos-pio/src/main.cpp @@ -111,7 +111,7 @@ void setup() .pixel_format = PIXFORMAT_JPEG, .frame_size = FRAME_SIZE, .jpeg_quality = JPEG_QUALITY, - .fb_count = 1, //2, + .fb_count = 2, .fb_location = CAMERA_FB_IN_DRAM, .grab_mode = CAMERA_GRAB_LATEST, // .sccb_i2c_port = -1 diff --git a/PlatformIO/esp32-cam-rtos-pio/src/streaming_all_frames.cpp b/PlatformIO/esp32-cam-rtos-pio/src/streaming_all_frames.cpp index 86debdc..f499245 100644 --- a/PlatformIO/esp32-cam-rtos-pio/src/streaming_all_frames.cpp +++ b/PlatformIO/esp32-cam-rtos-pio/src/streaming_all_frames.cpp @@ -212,8 +212,6 @@ void streamCB(void * pvParameters) { #if defined (BENCHMARK) streamAvg.value(micros()-streamStart); - fpsAvg.value(1000.0 / (float) (millis()-lastFrame) ); - lastFrame = millis(); streamStart = micros(); #endif @@ -260,7 +258,11 @@ void streamCB(void * pvParameters) { // Let other tasks run after serving every client if ( xTaskDelayUntil(&xLastWakeTime, xFrequency) != pdTRUE ) taskYIELD(); + #if defined (BENCHMARK) + fpsAvg.value(1000.0 / (float) (millis()-lastFrame) ); + lastFrame = millis(); + if ( millis() - lastPrint > BENCHMARK_PRINT_INT ) { lastPrint = millis(); Log.verbose("streamCB: wait avg=%d, stream avg=%d us, frame avg size=%d bytes, fps=%S\n", waitAvg.currentValue(), streamAvg.currentValue(), frameAvg.currentValue(), String(fpsAvg.currentValue())); diff --git a/PlatformIO/esp32-cam-rtos-pio/src/streaming_multiclient_queue.cpp b/PlatformIO/esp32-cam-rtos-pio/src/streaming_multiclient_queue.cpp index 33ade31..9575518 100644 --- a/PlatformIO/esp32-cam-rtos-pio/src/streaming_multiclient_queue.cpp +++ b/PlatformIO/esp32-cam-rtos-pio/src/streaming_multiclient_queue.cpp @@ -223,8 +223,6 @@ void streamCB(void * pvParameters) { #if defined (BENCHMARK) streamAvg.value(micros()-streamStart); - fpsAvg.value(1000.0 / (float) (millis()-lastFrame) ); - lastFrame = millis(); #endif // The frame has been served. Release the semaphore and let other tasks run. @@ -245,6 +243,11 @@ void streamCB(void * pvParameters) { // Let other tasks run after serving every client if ( xTaskDelayUntil(&xLastWakeTime, xFrequency) != pdTRUE ) taskYIELD(); +#if defined (BENCHMARK) + fpsAvg.value(1000.0 / (float) (millis()-lastFrame) ); + lastFrame = millis(); +#endif + #if defined (BENCHMARK) if ( millis() - lastPrint > BENCHMARK_PRINT_INT ) { lastPrint = millis(); diff --git a/PlatformIO/esp32-cam-rtos-pio/src/streaming_multiclient_task.cpp b/PlatformIO/esp32-cam-rtos-pio/src/streaming_multiclient_task.cpp index 070da51..b74a298 100644 --- a/PlatformIO/esp32-cam-rtos-pio/src/streaming_multiclient_task.cpp +++ b/PlatformIO/esp32-cam-rtos-pio/src/streaming_multiclient_task.cpp @@ -253,8 +253,6 @@ void streamCB(void * pvParameters) { info->frame = frameNumber; #if defined (BENCHMARK) streamAvg.value(micros()-streamStart); - fpsAvg.value(1000.0 / (float) (millis()-lastFrame) ); - lastFrame = millis(); #endif } } @@ -278,6 +276,9 @@ void streamCB(void * pvParameters) { if ( xTaskDelayUntil(&xLastWakeTime, xFrequency) != pdTRUE ) taskYIELD(); #if defined (BENCHMARK) + fpsAvg.value(1000.0 / (float) (millis()-lastFrame) ); + lastFrame = millis(); + if ( millis() - lastPrint > BENCHMARK_PRINT_INT ) { lastPrint = millis(); Log.verbose("streamCB: wait avg=%d, stream avg=%d us, frame avg size=%d bytes, fps=%S\n", waitAvg.currentValue(), streamAvg.currentValue(), frameAvg.currentValue(), String(fpsAvg.currentValue()));