-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy path[ino]-arduino-ESP32-code.ino
53 lines (41 loc) · 1.21 KB
/
[ino]-arduino-ESP32-code.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
#include "eloquent.h"
#include "eloquent/print.h"
#include "eloquent/tinyml/voting/quorum.h"
// replace 'm5wide' with your own model
// possible values are 'aithinker', 'eye', 'm5stack', 'm5wide', 'wrover'
#include "eloquent/vision/camera/m5wide.h"
#include "HogPipeline.h"
#include "HogClassifier.h"
Eloquent::TinyML::Voting::Quorum<7> quorum;
void setup() {
Serial.begin(115200);
delay(3000);
Serial.println("Begin");
camera.qqvga();
camera.grayscale();
while (!camera.begin())
Serial.println("Cannot init camera");
}
void loop() {
if (!camera.capture()) {
Serial.println(camera.getErrorMessage());
delay(1000);
return;
}
// apply HOG pipeline to camera frame
hog.transform(camera.buffer);
// get a stable prediction
// this is optional, but will improve the stability of predictions
uint8_t prediction = classifier.predict(hog.features);
int8_t stablePrediction = quorum.vote(prediction);
if (quorum.isStable()) {
eloquent::print::printf(
Serial,
"Stable prediction: %s \t(DSP: %d ms, Classifier: %d us)\n",
classifier.getLabelOf(stablePrediction),
hog.latencyInMillis(),
classifier.latencyInMicros()
);
}
camera.free();
}