Skip to main content

Neural Networks API

nn_api is a simple Face Filter with the API that allows you to work with different Neural Networks included into Face AR SDK.

Download Face Filter

nn_api effect API description#

nn_api effect consists of the following features:

  • Lips segmentation
  • Hair segmentation
  • Eyes segmentation (separate L/R)
  • Skin segmentation
  • Background segmentation

Based on that features effect can provide you with:

  • Lips recoloring (Matt or Shiny)
  • Hair recoloring
  • Eyes recoloring
  • Skin recoloring
  • Background replacement with image or video file

API#

There are several ways you can consume the effect API:

  • Via effect's config.js
  • In your application code use callJsMethod from Banuba SDK

Below you may see the code examples for different API use cases and languages.

When using effect API directly in the effect config.js you can write you own function and initiate desired parameters or use testAll function, which is already provided with a code example.

Mind to call your function (or uncomment testAll function) in the end of config.js file.

Lips coloring#

  • Lips.matt(rgbaString) - sets Matt lips color, following your rgbaString value, e.g. Lips.matt("1 0 1 1") for purple lips;
  • Lips.shiny(paramsString) - sets the additional parameters for Shiny lips:
    • value 1 - sCoef - color saturation (1 is optimal),
    • value 2 - vCoef - shine intensity (brightness, set 0 for matte lipstick)
    • value 3 - bCoef - brightness (1 is optimal)
    • value 4 - sCoef1 - shine bleeding (color saturation, set 0 for matte lipstick)
  • Lips.clear() - disable the feature and reset the color.
Lips.matt("1 0 0.49 1");
Lips.shiny("1 0.4 1 0.4");
// Lips.clear();

Preview

Drag

Hair coloring#

  • Hair.color(rgbaString) - set Hair color, following your rgbaString value, e.g. Hair.color("0 1 0 1") for green hair;
  • Hair.clear() - disable the feature and reset the color.
Hair.color("0.39 0.14 0.14 0.8");
// Hair.clear();

Preview

Drag

Eyes coloring#

  • Eyes.color(rgbaString) - set Eyes color, following your rgbaString value, e.g. Eyes.color("1 0 0 1") for red eyes;
  • Eyes.clear() - disable the feature and reset the color.
Eyes.color("0.2 0.2 0.8 0.64");
// Eyes.clear();

Preview

Drag

Skin coloring#

  • Skin.color(rgbaString) - set Eyes color, following your rgbaString value, e.g. Skin.color("0 1 0 1") for green skin;
  • Skin.clear() - disable the feature and reset the color.
Skin.color("0.8 0.4 0.2 0.33");
// Skin.clear();

Preview

Drag
Last updated on