Android Camera Plugin project

The AndroidCameraPlugin is Java plugin used for accessing and handling Android camera. It's use is demonstrated in VisageTrackerUnityDemo sample.

Building the project

The files related to Android Camera Plugin project are located in the Samples/Android/AndroidCameraPlugin sub-folder of the visage|SDK for Android folder.

Prerequisites to building the sample project are :

To build the AndroidCameraPlugin, please follow these steps:
  1. Open AndroidCameraPlugin project (located in Samples/Android) into Android Studio.
  2. Navigate to folder AndroidCameraPlugin/app/libs and delete existing file classes.jar
  3. Navigate to directoy where Unity is installed and copy file classes.jar (typically located in C:\Program Files\Unity\Editor\Data\PlaybackEngines?\androidplayer\Variations\mono\Development\Classes)
  4. Paste the file to AndroidCameraPlugin/app/libs
  5. Navigate to directoy where Unity is installed and copy directory tree unity3d (typically located in C:\Program Files\Unity\Editor\Data\PlaybackEngines?\androidplayer\Source\com)
  6. Paste the directory structure to AndroidCameraPlugin\app\src\main\java\com
  7. Open Gradle on the right and click "Refresh all Gradle projects" under Gradle projects
  8. Under Gradle projects, go to AndroidCameraPlugin -> Tasks -> other
  9. Double click on task exportJar and AndroidCameraPlugin.jar will be created in the AndroidCameraPlugin/app/release folder
  10. AndroidCameraPlugin.jar and AndroidManifest.xml should be replaced with new versions in Plugins/Android folder of your Unity project.
    NOTE: Package name in AndroidManifest.xml should match the package name in CameraActivity.jar

Implementation overview

Project is used for handling camera on Android. This is realised as Android activity which is created from C# script in Unity when the application starts. Switching between front and back facing camera is done by calling Android activity's functions from Unity script.
VisageTrackerUnityPlugin provides Java interface to events such as sending frames from camera to tracker and camera parameters changes.
AndroidCameraPlugin source code is available here.