Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

A Rock Paper Scissors game powered by HandPose from TensorflowJS, developed with Gatsby and deployed with Azure Static Web

License

Notifications You must be signed in to change notification settings

SugarDarius/rock-paper-scissors-pose-hand

Repository files navigation

Confront yourself against the posehand TensorflowJS model at Rock Paper Scissors game

GitHub package.json version

GitHub issues PRs welcome GitHub

say Twitter Follow

Greetings 👋

Rock Paper Scissors Pose Hand is a webapp to play the classic game "Rock Paper Scissors".
It uses the TensorflowJS model posehand developed with Gatsby with CharkraUI and deployed on Azure Static Web Apps.

A word about 💬

This project is still experimental and under development. So when using it you may endure issues or bugs.
The main goal here is to provide users some fun when interacting with an ML model which is here the TensorflowJS model posehand.

Feel free to open issues to increase the efficiency and the of this projet 😀.

How it works? 🤔

You wanna know how this project works? Here's how!

The ALGO

The ALGO is and algorithm which is your opponent.
He knows all the hand shapes available (and no the water well shape isn't correct 😇) for a rock paper sciossors game.

His own logic is very simple :
It will take this array as input:

['rock', 'paper', 'scissors']

And then shuffle it with a basic shuffle algorithm to finish with a random selection into the shuffled array.

As you can see for now it's very pretty basic, but maybe in futur I will complexify the logic to try to define the pattern of the player to block him 😜

You, the player

Here the things are a little more complex 😁

First, when the incantation READY?, ROCK!, PAPER!, SCISSORS! the webapp has to take a capture of your hand from the camera stream.
Then, the capture is rendered into a <canvas /> html tag to provide you preview of your hand.

After, to make the prediction of which shape is reprensented by your hand, the canvas his analysed by the posehand from TensorflowJS.
This will give the landmarks' coordinates of each fingers from your hand.

When the model has computed the coordinates I apply a logic to calcutate which fingers are open or not.
Each fingers are reprensented by four three-dimensionals points (x, y, z).
The logic to apply here is a mathematic formula to determnie if the angle in degrees between the first and the last point is more than 130deg or not
If we have and angle is more than 130deg so I suppose that your finger is open.

Based on this the logic determines which shape is represente by your hand 😀.

Requirements

As this webapp needs a stream from the webcam's user, he must give consent for the webapp use the camera.
And another requirement is that a network connection to internet required because of TensorflowJS specifications.

Special thanks 👏

I'd like to thanks Jen Looper which has gave an amazing talk about PoseDance at #AskTheExpert.
Her talk gave me the desire, the inspiration and the strength to carry out this project 😊.

Made with ❤ by SugarDarius

About

A Rock Paper Scissors game powered by HandPose from TensorflowJS, developed with Gatsby and deployed with Azure Static Web

Topics

Resources

License

Stars

Watchers

Forks