Beauty example app UI

Overview

Drag

The application is an example of using Banuba SDK to perform face beautification.

Structure

To work with some face beautification features you have to use a separate effect. In the application you can find several of them. One example features combined face beautification features and the others showcase specific tasks: hair, lips, skin, eyes coloring. The reason is high-performance requirements due to the usage of neural networks. In applications, these features can be combined based on the device possibilities and product requirements.

Beauty effect

There is a VSModel class in the project which contains the parameter setters each of which corresponds to parameters in the Beauty effect. The parameters are grouped for better representation on UI. The original list of parameters can be found in config.js file. In the example, the effect changes are applied with EffectPlayer.callJsMethod method inside MainActivity.onModelDataChanged callback which is emitted by any changes in the model. The value for JS call is a JSON string which is a regular set of key-value pairs. The effect values can be of two types: integer index and float value. The application uses SpinnerValueSetter and SeekBarValueSetter for that types of values.

Example:

public void onModelDataChanged(Map<String, String> values) {
String json = new JSONObject(values).toString();
mSdkManager.getEffectPlayer().callJsMethod("onDataUpdate", json);
}

More information about the effect and its parameters can be found here: beauty effect.

Neural networks

The examples given below are single feature effects. To switch them use EffectPlayer.loadEffect method. The only feature that can be modified is the color of segmental NN found fragment. In the example MainActivity.onColorChanged callback calls setColor effect method to apply a value.

Example:

public void onColorChanged(int argb) {
int a = (argb >> 24) & (0x000000FF);
int r = (argb >> 16) & (0x000000FF);
int g = (argb >> 8) & (0x000000FF);
int b = argb & (0x000000FF);
List<Float> color_arr = new ArrayList<>(4);
color_arr.add((float)r / 0xFF);
color_arr.add((float)g / 0xFF);
color_arr.add((float)b / 0xFF);
color_arr.add((float)a / 0xFF);
String json = new JSONArray(color_arr).toString();
mSdkManager.getEffectPlayer().callJsMethod("setColor", json);
}

Hair

Work example

Drag

Eyes

Work example

Drag

Lips

Work example

Drag

Skin

Work example

Drag
Last updated on