Skip to content

Commit 0bb7b95

Browse files
committed
fix(logging): Corrected FPS calculation
Previously, last_frame was only updated once at the beginning of stream_handler, leading to incorrect FPS and avg_frame_time computation. This commit ensures last_frame is updated on each iteration after last FPS computation, resulting in accurate FPS logging. Fixes espressif#10920
1 parent f22866f commit 0bb7b95

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,8 @@ static esp_err_t stream_handler(httpd_req_t *req) {
216216
size_t _jpg_buf_len = 0;
217217
uint8_t *_jpg_buf = NULL;
218218
char *part_buf[128];
219-
220219
static int64_t last_frame = 0;
221-
if (!last_frame) {
222-
last_frame = esp_timer_get_time();
223-
}
224-
220+
225221
res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);
226222
if (res != ESP_OK) {
227223
return res;
@@ -236,6 +232,11 @@ static esp_err_t stream_handler(httpd_req_t *req) {
236232
#endif
237233

238234
while (true) {
235+
236+
if (!last_frame) {
237+
last_frame = esp_timer_get_time();
238+
}
239+
239240
fb = esp_camera_fb_get();
240241
if (!fb) {
241242
log_e("Camera capture failed");

0 commit comments

Comments
 (0)