Skip to content

oleg-sta/FaceMaskExample

Repository files navigation

Face Mask example

What is it?

It's android example of Android application with Augmented Reality effects on face.

IMAGE ALT TEXT HERE

Unsigned APK file could be downloaded here: https://drive.google.com/file/d/1pRe2OyKeeM5-DZbs3Xz9TyZ9xORk-JIO/view?usp=sharing . Please add permission to camera.

This application uses VrFace library on Android. This project shows you how easily VrFace library could be used.

How to build?

Fork and clone this project.

Download model file from http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2. Unzip it, like this: bzip2 -d shape_predictor_68_face_landmarks.dat.bz2. As a result you should have file: shape_predictor_68_face_landmarks.dat, rename it to: sp68.dat, and put under the directory app/src/main/assets/. File size is about 70 Mbytes, that's why I don't want to put it under source control.

Note. Loading model sp68.dat is very heavy task, it can take several seconds or dozen seconds to be uploaded. You could try to retrain model and decrease size and therefore size of the application and initialization time.

Create local.properties in project root directory. Add two properties into file:

GITHUB_USER=YOU_GITHUB_USER_NAME
GITHUB_TOKEN=YOUR_GITHUB_TOKEN

put your github username instead of YOU_GITHUB_USER_NAME, to get YOUR_GITHUB_TOKEN open https://github.com/settings/tokens. Generate new token with read:packages permission. To read more about credentials please read here

Build project and install onto your phone. Add permission to Camera manually in your settings.

How it works?

It uses my library VrFace. This library makes all the work, please read description for more details. As it written in the library's description we need to implement only:

  • layout with com.stoleg.vrface.camera.FastCameraView for camera and GLSurfaceView for providing result
  • MainActivity initialize GLSurfaceView, initialize native library, add model for 3d face and model for points on the face
  • ShaderEffectMask implements shaders effects with shaders

You could just fork it or clone it and add your own effects.

Questions?

Just write me. Will glad to hear if it's useful.