Skip to content

Commit 313a42e

Browse files
committed
Fixed FPS calculation logging
the last_frame variable needs to be updated on each iteration, Immediately after computing the FPS of previous. Before this commit - the last frame was being updated only once at the beginning of stream_handler function. The fps and avg_frame_time computation were completely wrong. This commit fixes the computation. This commit - updates last_frame variable on each iteration. results is correct fps calculation.
1 parent f22866f commit 313a42e

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)