Skip to main content

Banuba SDK Android

image

The entry point to Banuba SDK is BanubaSdkManager class. This class provides the following functionality:

  • Configure rendering mode — setDrawSize, setAutoFaceOrientation, setFaceOrientation.
  • Set up the watermark — setWatermarkInfo.
  • Manage camera — openCamera, closeCamera, setCameraFacing, setCameraZoom, notifyGotCameraPermissions.
  • Open GL context management — releaseSurface, attachSurface, onSurfaceCreated, onSurfaceChanged, onSurfaceChanged, onSurfaceDestroyed.
  • Take a screenshot or image with the effect using the camera — takePhoto, processCameraPhoto.
  • Apply the effect to an external image (e.g. from disk) — processImage.
  • Record a video with the effect —startVideoRecording, stopVideoRecording.
  • Continuous photo rendering (i.e. the dynamic effect applied to the frozen image) — startEditingImage, stopEditingImage, takeEditedImage
  • Send frames to other destinations (e.g. via WebRTC) — startForwardingFrames, stopForwardingFrames.

banuba_sdk contains the following packages:

  • internal.camera — the functionality related to the camera capture. See Camera2 and CameraThread.
  • internal.encoding — audio and video capture and recording.
  • internal.gl — various Open GL ES utils.
  • internal.photo — screenshot capture.
  • internal.renderer — rendering thread. See RenderThread.

The Effect component makes up an essential part of the SDK usage. It's represented as a folder with scripts and resources. Please, refer to Android demo app section for more details about effects.

Configuring watermark

If you want to apply watermark to your photos, you should use mSdkManager.takePhoto(...) method.

Drawable watermarkDrawable = ContextCompat.getDrawable(this, R.drawable.my_watermark_resource);
int watermarkWidth = 101;
int watermarkHeight = 24;
float aspectRatio = watermarkWidth / watermarkHeight;
SizeProvider provider = viewportSize -> {
int targetWidth = (int)(viewportSize.getWidth() * 0.5f);
int targetHeight = (int)(targetWidth / aspectRatio);
return new Size(targetWidth, targetHeight);
};
PositionProvider positionProvider = new GravityPositionProviderAdapter(provider, Gravity.TOP | Gravity.LEFT);
WatermarkInfo watermarkInfo = new WatermarkInfo(watermarkDrawable, provider, positionProvider, watermarkWidth, watermarkHeight, true);
mSdkManager.setWatermarkInfo(watermarkInfo);
mSdkManager.takePhoto(null);

Binaries size

We include native debug symbols in our .aar archives, so you may find that banuba_effect_player.aar is too big (about 100 MB). These symbols will help us to get clear crash logs. Nevertheless, Android Studio will silently strip them from release apps, and no extra actions are required.

Still have any questions about FaceAR SDK for Android?

Visit our FAQ or contact our support.