It includes the main function to segment the SMPL and SMPL-X meshes into inside / outside / in-contact vertices. It includes contact losses that are used with SMPLify-XMC and TUCH.

Vertices in contact (blue) based on geodesic and euclidean distances. In this example, the geodesic threshold is 30 cm and the euclidean threshold is 2 cm. In red, detected self-intersecting vertices with segment tests.


1) Clone this repository

git clone [email protected]:muelea/selfcontact.git
cd selfcontact

2) Create python virtual environment and install requirements

python3 -m venv $YOUR_VENV_DIR/selfcontact
source $YOUR_VENV_DIR/selfcontact/bin/activate
pip install -r requirements.txt

To use the repo as python module, use pip install . instead and move on with step 3).

3) Download essentials

Download the essentials from here. These files are required and include for example the precomputed geodesic distances for the neutral SMPL-X and SMPL body modles. Unpack the essentions to ESSENTIALS_FOLDER

5) Run example script to test for self-intersections

# vertices in contact
python selfcontact/tutorial/ --essentials_folder ESSENTIALS_FOLDER --output_folder OUPUT_FOLDER
# intersecting vertices
python selfcontact/tutorial/ --essentials_folder ESSENTIALS_FOLDER --output_folder OUPUT_FOLDER

Mesh with result inside / outside segmentation WITHOUT segment tests. Note, how natural intersections, e.g. in the belly or crook regions are detected.

Mesh with result inside / outside segmentation WITH segment tests. With segment testing, these self-intersections are ignored.


  title = {On Self-Contact and Human Pose},
  author = {M{\"u}ller, Lea and Osman, Ahmed A. A. and Tang, Siyu and Huang, Chun-Hao P. and Black, Michael J.},
  booktitle = {Proceedings IEEE/CVF Conf.~on Computer Vision and Pattern Recog├čnition (CVPR)},
  month = jun,
  year = {2021},
  doi = {},
  month_numeric = {6}


We thank Vassilis Choutas for his implementation of the generalized winding numbers.