/
EdgeImpulse_FOMO_NO_PSRAM.ino
101 lines (88 loc) · 2.33 KB
/
EdgeImpulse_FOMO_NO_PSRAM.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* Run Edge Impulse FOMO model.
* It works on both PSRAM and non-PSRAM boards.
*
* The difference from the PSRAM version
* is that this sketch only runs on 96x96 frames,
* while PSRAM version runs on higher resolutions too.
*
* The PSRAM version can be found in my
* "ESP32S3 Camera Mastery" course
* at https://dub.sh/ufsDj93
*
* BE SURE TO SET "TOOLS > CORE DEBUG LEVEL = INFO"
* to turn on debug messages
*/
#include <your-fomo-project_inferencing.h>
#include <eloquent_esp32cam.h>
#include <eloquent_esp32cam/edgeimpulse/fomo.h>
using eloq::camera;
using eloq::ei::fomo;
/**
*
*/
void setup() {
delay(3000);
Serial.begin(115200);
Serial.println("__EDGE IMPULSE FOMO (NO-PSRAM)__");
// camera settings
// replace with your own model!
camera.pinout.aithinker();
camera.brownout.disable();
// NON-PSRAM FOMO only works on 96x96 (yolo) RGB565 images
camera.resolution.yolo();
camera.pixformat.rgb565();
// init camera
while (!camera.begin().isOk())
Serial.println(camera.exception.toString());
Serial.println("Camera OK");
Serial.println("Put object in front of camera");
}
void loop() {
// capture picture
if (!camera.capture().isOk()) {
Serial.println(camera.exception.toString());
return;
}
// run FOMO
if (!fomo.run().isOk()) {
Serial.println(fomo.exception.toString());
return;
}
// how many objects were found?
Serial.printf(
"Found %d object(s) in %dms\n",
fomo.count(),
fomo.benchmark.millis()
);
// if no object is detected, return
if (!fomo.foundAnyObject())
return;
// if you expect to find a single object, use fomo.first
Serial.printf(
"Found %s at (x = %d, y = %d) (size %d x %d). "
"Proba is %.2f\n",
fomo.first.label,
fomo.first.x,
fomo.first.y,
fomo.first.width,
fomo.first.height,
fomo.first.proba
);
// if you expect to find many objects, use fomo.forEach
if (fomo.count() > 1) {
fomo.forEach([](int i, bbox_t bbox) {
Serial.printf(
"#%d) Found %s at (x = %d, y = %d) (size %d x %d). "
"Proba is %.2f\n",
i + 1,
bbox.label,
bbox.x,
bbox.y,
bbox.width,
bbox.height,
bbox.proba
);
});
}
}