Skip to main content

How to use Face Triggers in Android

Face triggers allow users to activate filters using their facial expressions. Banuba SDK has several face triggers. To use them, you need to follow the next steps

Usage of Face Triggers in your Android app#

  1. Using BanubaSdkManager add FrameDataListener with implementation of onFrameDataProcessed method:

    sdkManager.getEffectPlayer().addFrameDataListener(
    new FrameDataListener() {
    @Override
    public void onFrameDataProcessed(@Nullable FrameData frameData) {
    // put the body here
    }
    }
    );
    note

    Remove FrameDataListener when it is not needed (e.g. when active UI component is deinited)

    sdkManager.getEffectPlayer().removeFrameDataListener(frameDataListenerObj);
  2. From FrameData object you can get information about smile, mouth, brows and others

    @Override
    public void onFrameDataProcessed(@Nullable FrameData frameData) {
    com.banuba.sdk.effect_player.Effect currentEffect = mSdkManager.getEffectManager().current();
    if (currentEffect != null && frameData != null) {
    String url = currentEffect.url();
    if (!url.isEmpty()) { // this check is necessary to prevent unnecessary calls
    try {
    frameData.getIsSmile(); //-> boolean
    frameData.getIsMouthOpen(); //-> boolean
    frameData.getIsBrowsRaised(); //-> boolean
    frameData.getIsBrowsShifted(); //-> boolean
    } catch (Throwable t) {
    // possible exceptions processing
    }
    }
    }
    }
  3. Now you can use Face Triggers in your Android app

Last updated on