Integrating visage|SDK into Unity project
visage|SDK allows easy integration with Unity 3D game engine using VisageTrackerUnityPlugin. VisageTrackerUnityPlugin is a wrapper that exposes VisageTracker's, VisageFaceAnalyser's and VisageFaceRecognition's functionalities for use in managed programming languages such as C# and Java.
In order to use visage|SDK in your own Unity project, libraries and selected data files need to be included. Unity sample application (VisageTrackerUnityDemo) is provided in visage|SDK as ready-to-build project with all necessary dependencies and can be used as a reference.
Following steps are required to integrate visage|SDK in your own project:
- Following libraries need to be added to project:
- Libraries libVisageVision.so, libVisageAnalyser.so, libTFPlugin.so, libc++_shared.so, libomp.so and libVisageTrackerUnityPlugin.so (located in lib folder)
- AndroidCameraPlugin.jar and AndroidManifest.xml (located in Samples/Android/AndroidCameraPlugin/app/release)
- Files and folders from Samples/data need to be copied to project's assets. Please note that you can copy the whole Samples/data folder with all of its subfolders and files, but if you want to reduce
the size of your application, here is a precise list:
- files from vfa, vfr and vft folders:
- List of data files required for face tracking can be found in VisageTracker documentation, specifically in class constructor VisageTracker::VisageTracker()
- NOTE: Please note that face analysis and face recognition are dependent on face tracking output.
- List of data files required for face analysis can be found in VisageFaceAnalysis documentation, specifically in method VisageFaceAnalyser::init()
- List of data files required for face recognition can be found in VisageFaceRecognition documentation, specifically in class constructor VisageFaceRecognition::VisageFaceRecognition()
- models located in vft/fm folder: <model_name>.wfm, <model_name>.fdp (more information about provided 3D models can be found in VisageTracker Configuration Manual).
- configuration file (e.g. Head Tracker.cfg)
- NeuralNet.cfg
- license key file (more information about how to include license key into your own project can be found here)
Running the application in Unity Editor
While developing an Android application, it can be useful to run and test the application in Unity Editor instead of having to build and push the app to Android device.
Since visage|SDK for Android only provides libraries that are intended to run on Android device, running the application in Unity Editor on your Windows or Mac development machine will
require downloading visage|SDK for that platform from the Visage Technologies Download Center.
Running the application in Unity Editor on Windows
After installing visage|SDK for Windows, simply navigate to
visageSDK/Samples/Unity/VisageTrackerUnityDemo/Assets/Plugins and copy Windows folder to your Unity project, specifically, to Plugins folder which should now
include Android and Windows folders.
When building the app for your Android device, platform in Build Settings should be set to Android and when running in Unity Editor it should be set to the platform of your development machine.
Running the application in Unity Editor on Mac
After installing visage|SDK for Mac, simply navigate to
visageSDK-macOS/lib and copy VisageTrackerUnityPlugin.bundle folder to your Unity project, specifically, to newly created Plugins/macOS folder which should now
include Android and macOS folders.
When building the app for your Android device, platform in Build Settings should be set to Android and when running in Unity Editor it should be set to the platform of your development machine.
It is important to note that VisageTrackerUnityPlugin API is not completely identical on different platform. A different approach is used for opening camera and fetching and displaying camera frames in the application.
That is why it is recommended to go through documentation of VisageTrackerUnityPlugin on both platforms and AndroidCameraPlugin
or simply use VisageTrackerUnityDemo as a basis for your own project. Specifically, all the differences between platforms that were mentioned are demonstrated in script Tracker.cs.