This project is a Unity-based application that connects computer vision (MediaPipe via Python) with a 3D hand in Unity and optionally a Raspberry Pi controlling servos.
The system captures hand movements via webcam, processes them in Python, and sends data to Unity to animate a rigged 3D hand in real time.
- Unity 6000.3.10f1
- Python (with MediaPipe setup)
- A working webcam
- (Optional) Raspberry Pi + servos
Some required .NET packages are NOT native to Unity and must be installed manually.
Make sure to import any missing dependencies if you encounter build/runtime errors.
Displays the webcam feed directly inside Unity.
Purpose:
- Captures webcam input
- Renders it as a background in the scene
Draws vertical lines from fingertip positions.
** Important Setup (Inspector):**
- You MUST assign the finger tip transforms
- The hand model must be rigged properly
Handles launching and closing Python scripts via terminal commands when scenes change.
Purpose:
- Starts MediaPipe tracking
- Stops processes when leaving a scene
- Enables communication between:
- Python → Unity
- Python → Raspberry Pi (servos)
- Specify the exact Python script name to launch/kill per scene
- Change the path in the script accordingly to your setup
Animates the 3D hand based on data received from Python.
Purpose:
- Receives hand tracking data
- Applies rotations to the hand rig
** Important Setup (Inspector):**
- Assign ALL hand bones
- Set the correct port for Python communication
** IMPORTANT NOTE:**
- The function
MoveBone()is calibrated for the provided hand model - If you use a different hand model, you MUST:
- Recalibrate
- Modify the
MoveBone()function accordingly
Loads the menu scene from other scenes.
Purpose:
- Scene navigation via UI buttons
Loads selected scenes from the menu.
** Important Setup (Inspector):**
- Provide the exact scene names
All scripts must be attached to Empty GameObjects in your scenes.
- The hand MUST be:
- Rigged
- Properly structured with bones
- If replaced:
- Update references in
MakeHandMove.cs - Rework
MoveBone()logic
- Update references in
-
Ensure all scenes are added to:
-
File → Build Settings → Scenes In Build
-
Scene names must match exactly with those used in inspectors
- Python scripts are launched via terminal commands
- Ensure:
- Python environment is correctly configured
- Script paths are valid
- Required libraries (MediaPipe, OpenCV, etc.) are installed
Webcam → Python (MediaPipe) → Hand tracking data → Unity (via socket) → 3D Hand Animation
(Optional) → Raspberry Pi → Servos
- Check port configuration
- Ensure Python script is running
- Verify socket connection
- Check fingertip references in
VerticalLineFromPoint
- Likely due to:
- Wrong bone assignment
- Different hand model → requires recalibration
- Verify script name in
PythonLaunchQuit - Check terminal permissions
- This project is not plug-and-play
- It requires:
- Proper calibration
- Correct rigging
- Careful inspector setup
- Pre-configured hand model (calibrated for current system)
- C# scripts for Unity integration
- Python communication pipeline (external)
If you modify:
- The hand model
- The tracking system
- The communication pipeline
Expect to adapt parts of the code, especially:
MakeHandMove.csMoveBone()function
Feel free to fork, improve, or adapt this system for your own projects.