Skip to main content

Segmentation

Segmentation feature allows users to remove, change and animate backgrounds and body parts without chroma key. Currently the following segmentation types are available:

- Background
- Body
- Face
- Hair
- Neck
- Skin
- Lips
- Brows
- Eyes (pupil, sclera, iris)

How to add Segmentation feature to your Effect

  1. Find SegmentationFeature.prefab in Project window, drag and drop it into your effect's Surface object in Hierarchy window.

image

  1. Provide SegmentationFeature script with the reference of your effect's CameraPlane object. Choose segmentation type from Type dropbox in Inspector window.

image

  1. Create and set custom material with BNB/Segmentation shader to Material property of RawImage component on SegmentationFeature object. You can find a simple example material in Assets => BanubaFaceAR => FeatureSegmentation => Materials folder.

image

  1. Effect is ready!

Segmentation with Unity Face AR SDK example scene

  1. Find and open SegmentationExample.unity scene under Assets => BanubaFaceAR => FeatureSegmentation => Scenes. image See full image

  2. Run the scene to see how it works.

image

Background segmentation example

Add Segmentation example to mobile device build

  1. Step for Android only: open Edit => Project Settings => Player and select Android tab. Remove Vulkan from the Graphics API (leave only OpenGLES3). It's better to restart Unity editor afterwards.

image See full image

  1. Open File => Build Settings and select your platform. Click Add Open Scenes to add SegmentationExample. Leave active only LoaderScene and SegmentationExample. Make sure their indexes are 0 and 1 respectively.

image

  1. Click Switch Platform and then Build And Run.