Shamsudheen
Published © MIT

Gesture Play

Play Rock-Paper-Scissors with just your hand gesture

BeginnerFull instructions provided2 hours91
Gesture Play

Things used in this project

Story

Read more

Code

XIAO ESP32S3

C/C++
 #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();

        int bestLabel = -1;
        int bestConfidence = 0;

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

            if (confidence > bestConfidence)
            {
                bestConfidence = confidence;
                bestLabel = label;
            }
        }

        if (bestConfidence >= 65)
        {
            switch (bestLabel)
            {
                case 0:
                    Serial.println("paper");
                    break;
                case 1:
                    Serial.println("rock");
                    break;
                case 2:
                    Serial.println("scissors");
                    break;
                default:
                    Serial.println("nothing");
                    break;
            }
        }
        else
        {
            Serial.println("nothing");
        }
    }
    else
    {
        Serial.println("nothing");
    }

    delay(100);  // Small delay between frames
}

Credits

Shamsudheen
3 projects • 2 followers

Comments