Skip to content

About

AR training prototype with Python hand tracking, MediaPipe/OpenCV, Unity UDP control, scoring, and CSV logging.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

20 Commits

Folders and files

Repository files navigation

SkillXR-AI

SkillXR-AI is an interactive AR training prototype that combines real-time webcam hand tracking with a Unity environment. It maps tracked movement into an AR training surface, compares the performed path with an ideal path, gives immediate rule-based feedback, calculates a performance score, and exports session measurements to CSV.

SkillXR-AI banner

What It Does

The Python component captures webcam frames with OpenCV, detects a hand with MediaPipe Hands, derives a normalized control point from the wrist and middle-finger-base landmarks, smooths the coordinates, and sends them to Unity over UDP. Unity uses those coordinates to move a tracked object, draw the performed path, compare it with a reference path, and report deviation, speed, stability, score, and corrective guidance.

System Architecture

flowchart LR
    A[Webcam] --> B[OpenCV]
    B --> C[MediaPipe Hands]
    C --> D[Python landmark processing]
    D --> E[Normalized x,y]
    E -->|UDP| F[Unity receiver]
    F --> G[Movement and path tracking]
    G --> H[Rule-based evaluation]
    H --> I[Corrective feedback and score]
    I --> J[CSV session logging]
Loading

The default configuration sends UTF-8 UDP datagrams to 127.0.0.1:5052. The host and port can be changed from the Python command line, while the receiver port is configurable in the Unity Inspector.

Implemented Features

  • Real-time webcam capture with OpenCV
  • MediaPipe Hands landmark detection
  • Smoothed, normalized hand-position output
  • UDP communication from Python to Unity
  • AR Foundation and ARCore configuration
  • AR plane detection and placement
  • Procedural ideal-path generation
  • Actual movement-path drawing
  • Movement-deviation evaluation
  • Speed and movement-stability evaluation
  • Performance scoring
  • Immediate directional and corrective feedback
  • Training-session start, stop, and reset controls
  • CSV logging with time, position, deviation, score, and status
  • Session summary with duration, average/max deviation, final score, accuracy, and grade

Technology Stack

  • Unity 2022.3.62f3
  • C#
  • AR Foundation 5.2.2
  • ARCore XR Plugin 5.2.2
  • Python
  • OpenCV
  • MediaPipe Hands
  • UDP networking
  • TextMeshPro and Unity UI
  • CSV file output

Project Structure

Assets/
  Scenes/SampleScene.unity          AR training scene
  Prefabs/placementObject.prefab    Training surface and runtime components
  Scripts/
    hand_tracking.py                Webcam, MediaPipe, smoothing, UDP sender
    UDPReceiver.cs                  Configurable Unity UDP receiver
    ARPlacement.cs                  AR plane placement and component wiring
    XRHandMotionController.cs       Coordinate mapping and smoothed movement
    IdealPath.cs                    Reference-path generation
    PathTracker.cs                  Actual-path drawing
    PathEvaluator.cs                Deviation, speed, stability, score, feedback
    SessionLogger.cs                CSV samples and session summary
    UIResetManager.cs               Session controls and live metrics
Images/                              Portfolio screenshots and banner
Packages/manifest.json              Unity package dependencies
requirements.txt                    Python package dependencies

Setup

1. Python environment

Use a supported Python environment and create an isolated virtual environment:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt

requirements.txt intentionally lists package names without version pins because compatible installed versions were not recorded in the source project. Pin tested versions before using the system in a controlled deployment.

2. Configure and run hand tracking

For Unity running on the same computer:

python Assets/Scripts/hand_tracking.py

The defaults are host 127.0.0.1 and port 5052. To send to another machine or AR device:

python Assets/Scripts/hand_tracking.py --host <unity-device-address> --port 5052

Press Esc in the OpenCV window to stop tracking.

3. Open and test the Unity project

  1. Open the repository in Unity 2022.3.62f3.
  2. Allow Unity to resolve the packages in Packages/manifest.json.
  3. Open Assets/Scenes/SampleScene.unity.
  4. Confirm that the UDPReceiver component uses the same port as the Python sender.
  5. Start hand_tracking.py, then enter Play mode to test the receiver, movement mapping, evaluation, and logging.

4. AR/mobile considerations

  • The project is configured with AR Foundation and ARCore for Android AR use.
  • A compatible ARCore device and camera permission are required for a device build.
  • If Python and Unity run on different devices, pass the Unity device's reachable network address with --host and permit UDP traffic on the configured port.
  • Network configuration varies by router, firewall, development machine, and AR device.

UDP Data Format

Each datagram contains two comma-separated normalized floating-point coordinates:

x,y

Both values originate from MediaPipe's normalized landmark coordinates. Unity remaps them into the local training-surface coordinate system.

Output and Analytics

SessionLogger.cs writes timestamped TrainingSession_*.csv files to Unity's Application.persistentDataPath. Each sample contains:

time,x,y,z,distance,score,status

The file concludes with session duration, average deviation, maximum deviation, final score, accuracy percentage, and a performance grade.

Screenshots

AR Placement

AR placement

Motion Tracking

Motion tracking

Session Analytics

Session analytics

Demo

Watch the 85-second SkillXR-AI demo on Vimeo

Limitations

  • Movement evaluation and coaching are deterministic and rule-based.
  • The current implementation does not use a trained machine-learning scoring model.
  • Webcam tracking runs in Python; AR interaction runs in Unity.
  • Cross-device operation requires an appropriate network address, matching port, and firewall configuration.
  • The dependency file is unpinned until a tested environment matrix is established.

Potential Extensions

The following are future possibilities, not implemented features:

  • Learned movement-quality models
  • Voice coaching
  • Cloud analytics and reporting
  • Learning-management-system integration
  • Multi-user training
  • Adaptive skill progression

Author

Dr. Ayaz Muhammad Hanif
iDeveloperz

License and Use

The repository currently states that the source, design, architecture, datasets, and documentation may not be copied, modified, distributed, or used commercially without explicit written permission from the author.

© 2026 Dr. Ayaz Muhammad Hanif

About

AR training prototype with Python hand tracking, MediaPipe/OpenCV, Unity UDP control, scoring, and CSV logging.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages