This repository contains AvatarStream, a tool for vtuber avatar tracking and streaming. It combines a Godot frontend with a Python backend for holistic tracking using MediaPipe.
- Frontend: Godot 4 project located in
game/AvatarStream/. - Backend: Python script (
holistic_tracker.py) using MediaPipe for pose/hand/face tracking. - Launcher:
run.pyin the root directory acts as the unified entry point. - Communication:
- Pose Data: UDP port 5005 (Python -> Godot).
- Video Frames: TCP port 5006 (Godot -> Python) for virtual camera output.
run.py: Main launcher. Checks dependencies and launches both processes.game/AvatarStream/: Godot project root.scripts/: GDScript logic.MediaPipeBridge.gd: Handles UDP reception and process management.VirtualCameraSender.gd: Handles TCP frame sending.
scripts/python/: Python backend.holistic_tracker.py: Main tracking logic.requirements.txt: Python dependencies.tests/: Unit tests.
gdextension_cmio/: C++ GDExtension for macOS CoreMedia I/O integration (Virtual Camera).- Uses SCons and CMake.
.github/workflows/: CI/CD configuration.
- Dependencies:
opencv-python,mediapipe,pyvirtualcam,pytest,pytest-mock,pyinstaller. - Installation:
run.pyattempts to auto-install fromgame/AvatarStream/scripts/python/requirements.txt. - Note:
run.pysetsAVATARSTREAM_LAUNCHED_BY_RUNNER=1to prevent Godot from trying to launch the Python script itself.
- Requires Godot 4.
- The project uses a GDExtension (
gdextension_cmio.gdextension) which may need to be compiled for macOS support.
- Located in
game/AvatarStream/scripts/python/tests/. - Run with
pytest. - Important: Tests mock
mediapipe,cv2, andpyvirtualcamto allow running in headless CI environments. - When writing new tests, ensure you mock these external dependencies if they rely on hardware or display.
- Testing is currently manual.
- Run Tests: Before submitting any changes to the Python backend, you MUST run the unit tests:
pytest game/AvatarStream/scripts/python/tests/
- Dependency Management: If you add a new Python library, add it to
game/AvatarStream/scripts/python/requirements.txt. - Launcher Logic: If modifying
run.py, ensure it correctly detects the frozen state (sys.frozen) to support compiled builds. - Protocol Changes: If you modify the data packet format in
holistic_tracker.py(UDP), you must also update the parsing logic ingame/AvatarStream/scripts/MediaPipeBridge.gdto match. - Virtual Camera: The virtual camera implementation relies on
pyvirtualcamin Python and a custom GDExtension on macOS. Be careful when modifying camera initialization logic.