MediaPipe in TouchDesigner 1

It is the part 1 of the tutorials introducing the use of the Google MediaPipe machine learning library in TouchDesigner. It will assume basic knowledge of TouchDesigner and fundamental coding skill in Python. The platform I am working on is a MacBook Pro running the OSX 11. TouchDesigner has its integrated Python programming environment. At the moment of writing, the Python version is 3.7. It also comes with a number of pre-installed external libraries, such as NumPy and OpenCV.

The first installation will be the Python programming language environment. I would recommend installing the official 3.7 version from the Python download website. Expand the dmg file and run the installer to install the proper Python version to the computer.

After we have the Python installed, the next step will be external libraries we would like to use in the Python environment. The target one is MediaPipe. We are going to use the pip command from the OSX Terminal. For general usage of the OSX Terminal, we can refer to the Terminal User Guide from Apple. For those who may have multiple Python versions installed, we can use the specific command pip3.7 to install the external libraries to make sure they are compatible with the TouchDesigner. For a brand new Python environment, the libraries it come with are:

  • pip
  • setuptools
  • wheel
pip list command

Pip is one of the package management system we can use in the Python environment. To install extra library such as the MediaPipe, we can type the following from the Terminal.

pip3.7 install --upgrade --user mediapipe
Install MediaPipe with pip

The following screenshot listed all the libraries we have after the installation.

The list of libraries after installing MediaPipe

After we ready the Python and the MediaPipe library, we can go back to TouchDesigner to enable it to link to the external libraries that we have installed outside it.

From the TouchDesigner pull down menu, choose Dialogs – Textport and DATs.

Textport and DATs

Inside the Textport, we can try to import OpenCV and list its current version.


The next step is to customise the external libraries location from the Preferences menu. From the pull down menu, choose TouchDesigner – Preferences – General.


Click the folder icon from the description, Python 64-bit Module Path. It will open up the file location dialog panel. Choose the home directory of your current user account. Since the Python libraries are installed inside the hidden Library folder, we need to type CMD SHIFT <period> to display all the hidden folders. Press the CMD, SHIFT and period “.” keys together. Choose the correct folder location as


and click Open.

External modules folder

Click the Save button for the Preferences panel.

Save the Preferences

After we save the preferences, we can verify the installation of MediaPipe from the Textport panel by importing the mediapipe module and list out some of its components.

import mediapipe as mp
Verify the MediaPipe installation

We are now ready to play with the MediaPipe library in TouchDesigner. The first one will be the face detection facility in a Script TOP.