Unity face tracking is an easy way to use head position in your interactive projects.
View Demo (6s vine video)
To use Unity Face Tracking, you need to download and install OpenTrack. This software is used to capture the head via your webcam. This project works with Unity free and pro.
####Opentrack
- Install and launch the software
- Select
FaceAPI
in Tracker Source. - Use
Flight Gear
as Game Protocol (use the port 5550, by default) - Press Start
####Unity
- Open Unity project
- Run the game. You are done !
###The code
FaceAPI is a powerfull real time 2D tracker. This software track the head-position in 3D providing X,Y,Z position and orientation coordinates per frame of video. Opentrack allow us to send this via the UDP protocol, on the local server. The head position data is stored in the ram. With unity 3D, the script UDPRecieve read the bytes, and decode it from hexa to float.
The UDPRecieve c#
script is located in the Standard Assets folder, to be compiled before the javascript
script. By doing this, we can make a gap between c#
and javascript
.
- Complete documentation
- Stanisław Halik (Opentrack team) for his help with byte decoding.