Shamsudheen
Published © MIT

NoPawZone

NoPawZone is a real-time pet detection digital signage system powered by the Grove Vision AI Module V2.

BeginnerWork in progress3 hours251
NoPawZone

Things used in this project

Story

Read more

Code

Arduino Code

Arduino
Here’s the Arduino code that runs on the ESP32-S3 and prints the pet detection status via serial
#include <Seeed_Arduino_SSCMA.h>
SSCMA Infer;

void setup()
{
    Serial.begin(9600);
    Infer.begin();
}

void loop()
{
    if (!Infer.invoke())  // If inference was successful
    {
        auto boxes = Infer.boxes();

        bool catDetected = false;
        bool dogDetected = false;

        // Check all detected boxes
        for (int i = 0; i < boxes.size(); i++)
        {
            int confidence = boxes[i].score;
            int label = boxes[i].target;

            // Only consider high-confidence detections
            if (confidence >= 60)
            {
                if (label == 0)
                    catDetected = true;
                else if (label == 1)
                    dogDetected = true;
            }
        }

        // Always print a result (moved outside the boxes.size() check)
        if (catDetected && dogDetected)
        {
            Serial.println("both");
        }
        else if (catDetected)
        {
            Serial.println("cat");
        }
        else if (dogDetected)
        {
            Serial.println("dog");
        }
        else
        {
            Serial.println("nothing");
        }
    }
    else
    {
        // If inference failed, still print something so React knows the state
        Serial.println("nothing");
    }

    delay(100);  // Wait 2 seconds before next detection
}

Credits

Shamsudheen
3 projects • 2 followers

Comments