Metadata-Version: 2.4
Name: mvmp
Version: 1.1.1
Summary: 3D Multi-View MediaPipe - Facial landmark detection for 3D meshes
Author-email: Giuseppe Facchi <giuseppe.facchi@outlook.com>
License: MIT License
        
        Copyright (c) 2026 Giuseppe Facchi
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/gfacchi-dev/mvmp
Project-URL: Repository, https://github.com/gfacchi-dev/mvmp
Project-URL: Issues, https://github.com/gfacchi-dev/mvmp/issues
Keywords: face,landmarks,3d,mediapipe,mesh
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Image Recognition
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mediapipe>=0.10.14
Requires-Dist: numpy<3.0,>=1.26.0
Requires-Dist: opencv-python>=4.11.0.86
Requires-Dist: pyrender>=0.1.45
Requires-Dist: pyrr>=0.10.3
Requires-Dist: pyglet<2
Requires-Dist: scipy>=1.11.0
Requires-Dist: trimesh>=4.0.0
Requires-Dist: embreex>=4.4.0
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Dynamic: license-file

# MVMP: 3D Multi-View MediaPipe

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![Framework](https://img.shields.io/badge/Framework-Python_3.11-yellow)](https://www.python.org/downloads/release/python-3110/) [![Face Landmarker](https://img.shields.io/badge/Model-MediaPipe_Face_Landmarker-red)](https://developers.google.com/mediapipe/solutions/vision/face_landmarker)

## Description

MVMP detects 478 MediaPipe-compatible 3D facial landmarks on textured meshes. 
It renders the mesh from 5 deterministic zone-based viewpoints (front, left/right sides, 
upper/lower), detects 2D landmarks with MediaPipe, and back-projects each to the mesh 
surface via raycasting. An optional Fibonacci-sphere auto-alignment phase orients the face 
toward +Z before detection.

**Supported mesh formats:** .obj, .ply, .stl, .gltf, .glb, .off

<img src="./img/pipelineOverview.png">

## Installation

```bash
pip install mvmp
```

The MediaPipe Face Landmarker model is bundled in the package.

### From Source

```bash
git clone https://github.com/gfacchi-dev/mvmp.git
cd mvmp
pip install .
```

## Usage

### Python API

```python
from mvmp import Facemarker

marker = Facemarker()
result = marker.predict("path/to/mesh.obj")
print(result)  # FacemarkerResult(478 landmarks, 478 vertex indices)

landmarks_3d = result.landmarks_3d              # dict[int, [x, y, z]]
vertex_indices = result.closest_vertices_ids    # dict[int, int]

result.save_json("landmarks.json")
```

#### Quiet mode / debug output

```python
marker = Facemarker(verbose=False)

# Save per-zone renders and auto-align report
marker = Facemarker(debug_output_dir="debug/")
```

#### Camera distance

```python
# Move cameras closer (0.5×) or farther (2×)
marker = Facemarker(camera_distance_multiplier=0.8)
```

#### Disable auto-alignment

```python
# Skip Fibonacci-sphere alignment (mesh assumed to already face +Z)
marker = Facemarker(auto_orient=False)
```

### Command Line

```bash
mvmp path/to/mesh.obj -o output/

# Process a folder
mvmp meshes/ -o results/

# With debug renders
mvmp mesh.obj --debug debug_output/

# Closer camera, no auto-align
mvmp mesh.obj --camera-distance 0.8 --no-auto-orient
```

**Arguments:**
- `path`: Mesh file or directory
- `-o, --output-path`: Output directory (default: `./output/`)
- `--debug`: Save debug renders and auto-align report to this directory
- `--camera-distance`: Camera distance multiplier (default: 1.0)
- `--no-auto-orient`: Skip Fibonacci-sphere auto-alignment

### Output Format

```json
{
  "coordinates": {"0": [x, y, z], ...},
  "closest_vertex_indexes": {"0": 12345, ...}
}
```

## Contributing

1. Fork the repository and create a feature branch.
2. Make your changes with clear commit messages.
3. Open a pull request.

## License

[MIT License](LICENSE)

## Contact

Questions or suggestions? Open an issue on [GitHub](https://github.com/gfacchi-dev/mvmp/issues).
