Real-time 3D face modeling application that captures facial landmarks using your webcam and generates a textured 3D mesh model. Features split-screen interface showing both live camera feed and interactive 3D model.
- 🎥 Real-time face landmark detection using MediaPipe
- 🔮 Live 3D mesh generation with Delaunay triangulation
- 🖼️ Interactive 3D model viewer with texture mapping
- 📺 Split-screen display showing camera feed and 3D model
- 🖱️ Model rotation using mouse controls
- 💾 Export functionality for 3D models (OBJ format with textures)
- Python 3.7+
- OpenGL-compatible graphics card
- Webcam
- 4GB+ RAM
-
Clone the repository:
git clone https://github.com/Dor-sketch/PyFace3D.git cd PyFace3D
-
Create and activate a virtual environment (optional but recommended):
# Windows python -m venv venv .\venv\Scripts\activate # macOS/Linux python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Activate virtual environment (if used):
# Windows .\venv\Scripts\activate # macOS/Linux source venv/bin/activate
-
Run application:
python3 main.py
Key/Action | Description |
---|---|
Left Mouse + Drag | Rotate 3D model |
S | Save model as OBJ |
R | Reset rotation |
Close Window | Exit application |
Click to expand architecture details
- MediaPipe Face Mesh (468 landmarks)
- Real-time confidence scoring
- Smooth landmark transitions
- 3D coordinate mapping
- Delaunay triangulation
- Normal vector calculation
- Texture coordinate mapping
- OpenGL-based rendering
- Split viewport management
- Dynamic texture updating
- Lighting system
- Configurable frame buffering
- Resolution scaling
- Memory management
- Vertex optimization
Models are saved with timestamp-based naming:
face_model_[timestamp].obj # Geometry
face_model_[timestamp].mtl # Materials
face_texture_[timestamp].png # Texture
This project has been tested on a MacBook Air M2 using Python 3.11.
Common Issues
- ✓ Check webcam connection
- ✓ Verify system permissions
- ✓ Try alternate camera index
- ✓ Adjust process_resolution
- ✓ Modify max_buffer_size
- ✓ Ensure proper lighting
- ✓ Update graphics drivers
- ✓ Verify PyOpenGL installation
- ✓ Check version compatibility
Contributions are welcome! Contributions guidelines will be added soon.
This project is licensed under the MIT License - see the LICENSE file for details.
- MediaPipe team for face mesh solution
- OpenGL and PyOpenGL communities
- Contributors to numpy, scipy, and pygame