Skip to content

cyprienti/Magic-Wand

Repository files navigation

Magic Wand Gesture Recognition

A gesture recognition system using accelerometer and gyroscope data to classify 3 magic gestures:
Stone , Paper , and Scissors — implemented with a Random Forest classifier.


Goal

Build a machine learning pipeline that:

  • Records wand gestures via motion sensors
  • Preprocesses and extracts features
  • Trains a classifier (Random Forest)
  • Predicts the gesture class in real-time

Features

  • Records motion sensor data (acceleration + gyroscope)
  • Visualizes sensor data over time
  • Preprocesses and standardizes features
  • Trains and evaluates a Random Forest model
  • Live prediction using trained model

Tech Stack

Layer Tool / Library
Data Viz matplotlib, pandas
ML Model scikit-learn
Preproc pandas, joblib, os
Input CSV recordings (6-axis data)

File Overview

├── recordings/ # Raw gesture data (CSV) ├── features/ # Extracted feature vectors ├── graphs/ # Saved plots of motion data ├── preprocess.py # Feature extraction + labeling ├── train_classifier.py # Train + evaluate + save model ├── yourcode.py # Predict spell from new gesture ├── plot_graphs.py # Plot gesture data ├── README.md # Project description



Getting Started

1. Install Dependencies

pip install pandas matplotlib scikit-learn joblib
  1. Collect and Save Gesture Recordings Each recording is saved as a CSV with columns: time, accX, accY, accZ, gyroX, gyroY, gyroZ

Save recordings to the recordings/ folder. Make sure filenames contain "Stone", "Paper", or "Scissors" to label them correctly.

  1. Preprocess Data
python preprocess.py

Extracts mean, std, min, max from all 6 channels

Adds gesture labels

Saves result to features/features.csv

  1. Train the Classifier
python train_classifier.py

Loads features

Splits data (80% training, 20% test)

Trains Random Forest model

Evaluates performance

Saves random_forest_model.pkl

  1. Predict on New Gestures
python yourcode.py

Loads a new CSV from recordings/

Extracts features

Predicts the gesture with the trained model

Outputs predicted class (stone/paper/scissors)

About

A Magic Wand project that recognizes three differents spells using motion gestures (stone, paper, scissors). Sensor data is collected and used to train a classifier that detects which spell is cast based on the wand's movements

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages