Skip to content

Commit

Permalink
added FPS print method for measure performance
Browse files Browse the repository at this point in the history
  • Loading branch information
hpsaturn committed Jan 20, 2024
1 parent e97b2c2 commit 2e247fd
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions examples/freenove-basic/freenove-basic.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
#include <Arduino.h>
#include "CamFreenove.h"

#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
#include "esp32-hal-log.h"
#define TAG ""
#else
#include "esp_log.h"
static const char *TAG = "camera_basic";
#endif

#define CONVERT_TO_JPEG
// #define CONVERT_TO_JPEG

CamFreenove Camera;

Expand All @@ -30,17 +22,30 @@ void setup() {
}
}

uint16_t frame = 0;

void printFPS(const char *msg) {
static uint_least64_t timeStamp = 0;
frame++;
if (millis() - timeStamp > 1000) {
timeStamp = millis();
Serial.printf("%s %2d FPS\r\n",msg, frame);
frame = 0;
}
}

void loop() {
if (Camera.get()) {
#ifdef CONVERT_TO_JPEG
uint8_t *out_jpg = NULL;
size_t out_jpg_len = 0;
frame2jpg(Camera.fb, 64, &out_jpg, &out_jpg_len);
Serial.println("frame2jpg ready");
// CoreS3.Display.drawJpg(out_jpg, out_jpg_len, 0, 0, dw, dh);
printFPS("JPG compression at");
// Display.drawJpg(out_jpg, out_jpg_len, 0, 0, dw, dh);
free(out_jpg);
#else
// CoreS3.Display.pushImage(0, 0, dw, dh, (uint16_t *)CoreS3.Camera.fb->buf);
printFPS("frame ready at");
// Display.pushImage(0, 0, dw, dh, (uint16_t *)CoreS3.Camera.fb->buf);
#endif
Camera.free();
}
Expand Down

0 comments on commit 2e247fd

Please sign in to comment.