3D Face Reconstruction

From a photo of a face, service predicts gender, shape blendshapes, UV face texture, hair color, skin color, the presence of glasses.

1. Getting a token

Getting a token

2. Choice of photo

Choose a photo of a person.

Note: Please send a photo of one person.

Note: The quality of the photo must be a fairly good resolution.

Note: The face should not be a full face and not covered by foreign objects.

Note: Lighting should not have hard drops and shadows.

Note: The photo should have neutral lighting. Otherwise the skin color will be unrealistic.

Note: The correct result is issued for persons over 18 years of age. Children may have problems with gender determination.

Note: The best result will be with neutral facial emotions.

Need a successful image? Download a sample

3. Reconstruct 3D Face

Make a request by sending your chosen photo.

token="ENTER_YOUR_TOKEN"
image_path="ENTER_IMAGE_PATH"

curl -X 'POST' 'https://api.metahumansdk.io/face_recon/run_pipeline' \
  -H 'accept: application/json' \
  -H 'Content-Type: multipart/form-data' \
  -F "token=$token" \
  -F "image_bytes=@$image_path;type=image/png" > head_config.json

Note: Do not forget to replace the details in the request with your own.

Expected output:

After successful execution of the code, you should receive the following type of json in head_config.json file:

{
  "result": {
    "face": {
      "textureUrl": str,
      "blendShapes": list,
      "blinkCorrectionCoeff": double
    },
    "hair": {
      "color": hex color,
      "type": str
    },
    "skin": {
      "color": hex color
    },
    "accessories": list,
    "gender": str
  }
}

At the moment we have received information about the person. Now let's download the face texture.

4. Download UV face texture

The json we received in the last step contains the url where we can download the texture.

texture_url=$(cat head_config.json | python -c 'import sys, json; print(json.load(sys.stdin)["result"]["face"]["textureUrl"])')

curl -X 'GET' "https://api.metahumansdk.io/face_recon/${texture_url}" > uv.png

After the completed stages, you get a uv texture uv.png and information about the face head_config.json.

5. Visualization

In order to get a 3D model of the head, we will use GLB Constructor:

token="ENTER_YOUR_TOKEN"

curl -X 'POST' 'https://api.metahumansdk.io/glb_const/assemble' \
    -H 'accept: application/json' \
    -H 'Content-Type: multipart/form-data' \
    -F "token=$token" \
    -F 'head_uv=@uv.png;type=image/png' \
    -F 'head_config=@head_config.json;type=application/json' \
    -F 'add_facs=true' > head.glb

After the completed stages, you get a glb model head.glb .

To add hair to the head model please follow to 3D Hair Reconstruction.

Last updated