Skip to content

Commit a4e2fe8

Browse files
committed
Add basic_fps_logger example with main.cpp, CMakeLists, and README
1 parent 9fde0e7 commit a4e2fe8

File tree

3 files changed

+156
-0
lines changed

3 files changed

+156
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
# Include main project components
4+
set(EXTRA_COMPONENT_DIRS "../../components")
5+
6+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
7+
project(basic_fps_logger)
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Basic FPS Logger Example
2+
3+
This example provides the minimal working demonstration of the **CCM ESP32 Vision Node**:
4+
5+
- Initialize the ESP32-S3 camera
6+
- Capture frames in a loop
7+
- Measure and log frames-per-second (FPS)
8+
- Validate hardware, PSRAM, and camera configuration
9+
10+
It serves as the baseline sanity check before adding any image-processing stages.
11+
12+
---
13+
14+
## Who This Example Is For
15+
16+
- Embedded developers bringing up ESP32-S3 camera hardware
17+
- Robotics / IoT engineers running a small smart-camera node
18+
- Engineering leads evaluating CCM Code’s firmware structure
19+
- Anyone validating that their board + camera module is wired and configured correctly
20+
21+
---
22+
23+
## Hardware Requirements
24+
25+
Recommended and tested target:
26+
27+
- ESP32-S3 dev board with PSRAM
28+
- Camera module:
29+
- OV2640
30+
- OV5640
31+
- Example boards:
32+
- Seeed XIAO ESP32-S3 Sense
33+
- ESP32-S3-EYE
34+
- AI-Thinker ESP32-S3-CAM
35+
36+
Required tools:
37+
38+
- USB cable
39+
- ESP-IDF v5 or newer
40+
- Serial monitor (`idf.py monitor` or VS Code ESP-IDF extension)
41+
42+
---
43+
44+
## How to Build & Run
45+
46+
From the repository root:
47+
48+
```bash
49+
cd firmware
50+
idf.py set-target esp32s3
51+
idf.py menuconfig # configure serial port and camera pins if needed
52+
idf.py build
53+
idf.py flash monitor
54+
```
55+
56+
This example is the default firmware entry point (`firmware/main/main.cpp`).
57+
If additional examples are added later, use a compile-time switch or Kconfig option to select them.
58+
59+
---
60+
61+
## Expected Serial Output
62+
63+
If everything is configured correctly, you should see logs similar to:
64+
65+
```text
66+
I (200) camera_node: Camera initialized: 320x240, PIXFORMAT_RGB565
67+
I (210) main: Starting capture loop...
68+
I (1210) main: Frame 100, avg FPS = 28.7, min = 26.4, max = 30.1
69+
I (2210) main: Frame 200, avg FPS = 28.9, min = 26.2, max = 30.3
70+
```
71+
72+
This verifies:
73+
74+
- Proper camera pin configuration
75+
- PSRAM buffers are stable
76+
- Frame acquisition loop is running
77+
- Timing metrics are correct
78+
79+
If you see camera initialization errors, re-check:
80+
81+
- Pin assignments
82+
- PSRAM stability in `menuconfig`
83+
- Sensor module orientation
84+
85+
---
86+
87+
## What to Try Next
88+
89+
After FPS logging works:
90+
91+
- Increase resolution and compare FPS
92+
- Enable grayscale or early `CvPipeline` stages
93+
- Add logging of per-stage timings
94+
- Move toward blob detection and MJPEG streaming
95+
96+
The FPS logger is intentionally simple — it is your reference baseline as the vision node grows.
97+
98+
---
99+
100+
## File Structure
101+
102+
```text
103+
examples/
104+
└── basic_fps_logger/
105+
├── README.md <-- this file
106+
└── (future) CMakeLists.txt or example-specific config
107+
```
108+
109+
Additional example variants (blob detection, ROI cropping, streaming) will live beside this one.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <esp_log.h>
2+
#include <esp_timer.h>
3+
#include "CameraNode.hpp"
4+
5+
static const char* TAG = "fps_example";
6+
7+
extern "C" void app_main() {
8+
ESP_LOGI(TAG, "Starting FPS Logger Example");
9+
10+
CameraNode camera;
11+
if (!camera.init()) {
12+
ESP_LOGE(TAG, "Camera init failed! Check pin definitions in CameraNode.cpp");
13+
return;
14+
}
15+
16+
int64_t last_time = esp_timer_get_time();
17+
int frame_count = 0;
18+
19+
while (true) {
20+
camera_fb_t* fb = camera.capture();
21+
if (!fb) {
22+
ESP_LOGE(TAG, "Frame capture failed");
23+
continue;
24+
}
25+
26+
// Simulating processing time could go here
27+
28+
camera.release(fb);
29+
frame_count++;
30+
31+
// Log every 100 frames to keep output clean
32+
if (frame_count % 100 == 0) {
33+
int64_t now = esp_timer_get_time();
34+
float fps = 100.0f / ((now - last_time) / 1000000.0f);
35+
ESP_LOGI(TAG, "Throughput: %.2f FPS | Resolution: %ux%u", fps, fb->width, fb->height);
36+
last_time = now;
37+
frame_count = 0;
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)