Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // include your library created here
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- #include <eloquent_esp32cam.h>
- #include <eloquent_esp32cam/edgeimpulse/fomo.h>
- using eloq::camera;
- using eloq::ei::fomo;
- // Initialize the LCD (I2C address 0x27, 16 columns, 2 rows)
- LiquidCrystal_I2C lcd(0x27, 16, 2);
- void setup() {
- delay(3000);
- Serial.begin(115200);
- Serial.println("__EDGE IMPULSE FOMO (NO-PSRAM)__");
- // Initialize I2C LCD
- Wire.begin(14, 15); // SDA = GPIO 14, SCL = GPIO 15
- lcd.init();
- lcd.backlight();
- lcd.setCursor(0, 0);
- lcd.print("Initializing...");
- // Camera settings
- camera.pinout.aithinker(); //replace aithinker with your model of your ESP32cam
- camera.brownout.disable();
- camera.resolution.yolo();
- camera.pixformat.rgb565();
- // Initialize camera
- while (!camera.begin().isOk()) {
- Serial.println(camera.exception.toString());
- lcd.setCursor(0, 1);
- lcd.print("Cam Error!");
- }
- Serial.println("Camera OK");
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Ready!");
- }
- void loop() {
- // Capture picture
- if (!camera.capture().isOk()) {
- Serial.println(camera.exception.toString());
- lcd.setCursor(0, 1);
- lcd.print("Capture Failed");
- return;
- }
- // Run FOMO inference
- if (!fomo.run().isOk()) {
- Serial.println(fomo.exception.toString());
- lcd.setCursor(0, 1);
- lcd.print("Inference Error");
- return;
- }
- // Display number of detected objects
- Serial.printf("Found %d object(s) in %dms\n", fomo.count(), fomo.benchmark.millis());
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.printf("Objects: %d", fomo.count());
- // If no objects detected, return
- if (!fomo.foundAnyObject()) {
- lcd.setCursor(0, 1);
- lcd.print("No object found");
- return;
- }
- // Display detected object
- lcd.setCursor(0, 1);
- lcd.printf("%s", fomo.first.label);
- Serial.printf("Found %s at (x = %d, y = %d) (size %d x %d). Proba: %.2f\n",
- fomo.first.label, fomo.first.x, fomo.first.y,
- fomo.first.width, fomo.first.height, fomo.first.proba);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement