MediaPipe for TouchDesigner
- MediaPipe for TouchDesigner
- On Apple Silicon (M1) using Rosetta2
We will install an emulated x86_64 brew using Rosetta2 alongside native Apple Silicon brew. This way we can install the by TouchDesigner expected python3.7 while also installing the MediaPipe module.
There is a MediaPipe module build for Apple Silicon (M1) machines found at [this Github issue](https://github.com/google/mediapipe/issues/3277), but I couldn't find a native Python 3.7 build for Apple Silicon to run in TouchDesigner.
- 1. Install brew x86_64 using Rosetta2
```bash $ arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" ```
- 2. Make alias for x86_64 brew
Add this to rc file (.bashrc, .zshrc etc)
```bash alias ibrew="arch -x86_64 /usr/local/bin/brew" ```
- 3. Install python3.7
```bash $ ibrew install python@3.7 ```
- 4. Alias for python@3.7 and pip3
Add to rc file
```bash alias iPY37=/usr/local/opt/python@3.7/bin/python3 alias iPIP37=/usr/local/opt/python@3.7/bin/pip3 ```
Now you can use `iPY37` to run x86_64 python@3.7 and `iPIP37` to install packages.
- 5. Install Mediapipe for python@3.7 x86_64
```bash $ iPIP37 install mediapipe ```
- 6. Find python@3.7 x86_64 module path
Find the Python Module path of installed x86_64 python@3.7
``` $ ibrew --prefix
/usr/local ```
Append `/lib/python3.7/site-packages` to this path to get `/usr/local/lib/python3.7/site-packages`. This is the *Python 64-bit Module Path* you need to fill in TouchDesigner by going to `Preferences -> general -> Python 64-bit Module Path`
- 7. Restart TouchDesigner
Mediapipe should be installed! To verify the installation go to `Dialogs -> Textport and DATs`, import the MediaPipe module; `import mediapipe as mp` and list the components; `print(dir(mp.solutions))`
- Windows
For windows we need to have a parallel copy of the same Python version on the harddrive. TouchDesigner expects us to work with Python3.7.x so grab this version from the [Python website](https://www.python.org/downloads/windows/). I used [Python 3.7.9](https://www.python.org/ftp/python/3.7.9/python-3.7.9-amd64.exe) for this tutorial.
- 1. Install excecutable
Double-click the downloaded executable file and install Python to the `DataStorage` drive `E:/` in a folder named `Python`
- 2. Installing MediaPipe
To install MediaPipe for our newly installed Python, open Windows PowerShell and run the following commands
```dos $ python
... Python 3.7.9 ...
$ exit() ```
- Note: Check if the Python version corresponds with the Python you've installed in step 1.*
Install mediapipe using pip package manager:
``` $ pip install mediapipe ```
- 3. Open TouchDesigner starter
Download the [MediaPipe starter project](http://interactionstation.wdka.hro.nl/mediawiki/images/a/a5/Mp-starter-toe.zip), unzip it and double-click to open the project in TouchDesigner. If you installed Python3.7 in a different folder than `E:\Python\Lib\site-packages` you need to change the `pythonpath` variable within the `DAT Excecute` OP to the correct folder.
To check if you can use MediaPipe in TouchDesigner, navigate to `Dialogs -> Textport and DATs`, import the MediaPipe module; `import mediapipe as mp` and list the components; `print(dir(mp.solutions))`.