image collection code
This commit is contained in:
parent
ec305108a6
commit
1d22dbfa3a
|
@ -16,7 +16,8 @@ Following can be observed from the video:
|
|||
- **Memory** Consumes only 1 kB of RAM - difference between the RAM calculated by Arduino IDE before and after adding the TinyML-CAM image recognition system.
|
||||
|
||||
### Code
|
||||
|
||||
- [[ipynb]-TinyML-CAM-full-code-with-markdown.ipynb](https://github.com/bharathsudharsan/TinyML-CAM/blob/main/%5Bipynb%5D-TinyML-CAM-full-code-with-markdown.ipynb)
|
||||
- [[h]-HOG-plus-RandomForest-classifier.h](https://github.com/bharathsudharsan/TinyML-CAM/blob/main/%5Bh%5D-HOG-plus-RandomForest-classifier.h)
|
||||
- [[ino]-arduino-ESP32-code.ino](https://github.com/bharathsudharsan/TinyML-CAM/blob/main/%5Bino%5D-arduino-ESP32-code.ino) - upload to
|
||||
- [[ino]-CameraWebServer.ino]()
|
||||
- [[ipynb]-TinyML-CAM-full-code-with-markdown.ipynb](https://github.com/bharathsudharsan/TinyML-CAM/blob/main/%5Bipynb%5D-TinyML-CAM-full-code-with-markdown.ipynb) -
|
||||
- [[h]-HogClassifier.h](https://github.com/bharathsudharsan/TinyML-CAM/blob/main/%5Bh%5D-HogClassifier.h) - Contains the RandomForestClassifier trained using the collected image data.
|
||||
- [[h]-HogPipeline.h](https://github.com/bharathsudharsan/TinyML-CAM/blob/main/%5Bh%5D-HogPipeline.h) - Contains the HOG features extrator for image frames.
|
||||
- [[ino]-arduino-ESP32-code.ino](https://github.com/bharathsudharsan/TinyML-CAM/blob/main/%5Bino%5D-arduino-ESP32-code.ino) - Upload to ESP32 along with the above two .h files. After upload, put your objects in front of the camera to see predicted labels.
|
||||
|
|
|
@ -0,0 +1,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();
|
||||
}
|
Loading…
Reference in New Issue