Skip to content

Android API Reference

Log Levels

Log level enumeration for controlling log output levels.

java
public enum LogLevel {
  TRACE(0, "TRACE"),
  DEBUG(1, "DEBUG"),
  INFO(2, "INFO"),
  WARN(3, "WARN"),
  ERROR(4, "ERROR"),
  CRITICAL(5, "CRITICAL");
}

Log Configuration Class

Log configuration class for configuring log output methods and levels.

Field Descriptions:

  • consoleEnabled: Whether to enable console output
  • fileEnabled: Whether to enable file output
  • level: Log level
  • fileName: Log file path (only effective when fileEnabled is true)
java
public static class LogConfig {
  public boolean consoleEnabled;
  public boolean fileEnabled;
  public LogLevel level;
  public String fileName;

  public LogConfig();
  public LogConfig(boolean consoleEnabled, boolean fileEnabled, LogLevel level, String fileName);
}

Process Mode

Image processing mode enumeration.

  • IMAGE: Image mode, suitable for single image processing
  • VIDEO: Video mode, suitable for video streams and live streaming scenarios, better performance
java
public enum ProcessMode {
  IMAGE(0), // Image mode
  VIDEO(1); // Video mode
}

Engine Configuration

Engine configuration class for initializing the beauty engine.

Field Descriptions:

  • appId: Application ID (optional, not required if licenseJson is provided)
  • appKey: Application key (optional, not required if licenseJson is provided)
  • licenseJson: License data JSON string (optional, if provided, takes priority and appId and appKey are not required)

Methods:

  • isValid(): Validate if configuration is valid
    • If licenseJson is provided, use license data verification
    • Otherwise, require appId and appKey for automatic online verification
java
public static class EngineConfig {
  public String appId;
  public String appKey;
  public String licenseJson;  // License data JSON string (optional)

  public EngineConfig();
  public EngineConfig(String appId, String appKey);
  public boolean isValid();
}

Engine Interface

Main beauty effect engine class providing entry point for beauty functionality.

Static Methods:

  • setLogConfig(LogConfig config): Set log configuration

Instance Methods:

Initialization and Release

  • BeautyEffectEngine(Context context, EngineConfig config): Constructor, create engine instance
  • void release(): Release engine resources

Beauty Type Control

  • int enableBeautyType(BeautyType type, boolean enabled): Enable or disable beauty type
  • boolean isBeautyTypeEnabled(BeautyType type): Check if beauty type is enabled
  • int disableAllBeautyTypes(): Disable all beauty types

Parameter Settings

  • int setBeautyParam(BasicParam param, float value): Set basic beauty parameters (range 0.0 - 1.0)
  • int setBeautyParam(ReshapeParam param, float value): Set face reshape parameters (range 0.0 - 1.0)
  • int setBeautyParam(MakeupParam param, float value): Set makeup parameters (range 0.0 - 1.0)
  • int setVirtualBackground(VirtualBackgroundOptions options): Set virtual background
    • Parameter: VirtualBackgroundOptions object containing background mode and background image
    • Return value: 0 indicates success, -1 indicates engine not initialized, -2 indicates invalid parameters (options is null or invalid)

Image Processing

  • ImageFrame processImage(ImageFrame inputFrame, ProcessMode processMode): Process image frame

Return Value Descriptions:

  • Methods return int type:
    • 0 indicates success
    • -1 indicates engine not initialized
    • -2 indicates invalid parameters (only for setVirtualBackground method)
  • processImage returns ImageFrame: Processed image frame, returns null on failure
java
public class BeautyEffectEngine {
  public static void setLogConfig(LogConfig config);
  
  public BeautyEffectEngine(Context context, EngineConfig config);
  public void release();
  
  public int enableBeautyType(BeautyType type, boolean enabled);
  public boolean isBeautyTypeEnabled(BeautyType type);
  public int disableAllBeautyTypes();
  
  public int setBeautyParam(BasicParam param, float value);
  public int setBeautyParam(ReshapeParam param, float value);
  public int setBeautyParam(MakeupParam param, float value);
  public int setVirtualBackground(VirtualBackgroundOptions options);
  
  public ImageFrame processImage(ImageFrame inputFrame, ProcessMode processMode);
}

Beauty Parameters

Beauty parameter enumeration classes containing all beauty-related parameter type definitions.

Beauty Types

Define available beauty functionality types.

java
public enum BeautyType {
  BASIC(0),        // Basic beauty
  RESHAPE(1),      // Face reshape
  MAKEUP(2),       // Makeup effects
  VIRTUAL_BACKGROUND(3); // Virtual background
}

Basic Beauty Parameters

Basic beauty effect parameter types, all parameter value ranges are 0.0 - 1.0.

java
public enum BasicParam {
  SMOOTHING(0),  // Smoothing
  SHARPENING(1), // Sharpening
  WHITENING(2),  // Whitening
  ROSINESS(3);   // Rosiness
}

Face Reshape Parameters

Face reshape effect parameter types, all parameter value ranges are 0.0 - 1.0.

java
public enum ReshapeParam {
  FACE_THIN(0),      // Face thinning
  FACE_V_SHAPE(1),   // V-shaped face
  FACE_NARROW(2),    // Narrow face
  FACE_SHORT(3),     // Short face
  CHEEKBONE(4),      // Cheekbone
  JAWBONE(5),        // Jawbone
  CHIN(6),           // Chin
  NOSE_SLIM(7),      // Nose slimming
  EYE_SIZE(8),       // Eye enlargement
  EYE_DISTANCE(9);   // Eye distance
}

Makeup Parameters

Makeup effect parameter types, all parameter value ranges are 0.0 - 1.0.

java
public enum MakeupParam {
  LIPSTICK(0),  // Lipstick
  BLUSH(1);     // Blush
}

Virtual Background Options

Virtual background effect configuration options.

java
public static class VirtualBackgroundOptions {
  public BackgroundMode mode = BackgroundMode.NONE;
  public ImageFrame backgroundImage = null;
  
  public VirtualBackgroundOptions() {}
  
  public VirtualBackgroundOptions(BackgroundMode mode) {
    this.mode = mode;
  }
}

ImageFrame

Image frame class for encapsulating image data and processing.

Creation Methods:

  • createWithFile(String filePath): Create from file (supports PNG, JPG)
  • createWithRGBA(ByteBuffer data, int width, int height, int stride): Create from RGBA data
  • createWithBGRA(ByteBuffer data, int width, int height, int stride): Create from BGRA data
  • createWithI420(...): Create from I420 YUV data
  • createWithAndroid420(...): Create from Android Camera2 YUV_420_888 format

Image Operations:

  • int rotate(ImageBuffer.Rotation rotation): Rotate image (returns 0 for success)
  • boolean isValid(): Check if image frame is valid

Format Conversion:

  • toRGBA(), toBGRA(), toRGB(), toBGR(): Convert to RGB formats
  • toI420(), toNV12(), toNV21(): Convert to YUV formats

Resource Management:

  • void release(): Release native resources
java
public class ImageFrame {
  public static ImageFrame createWithFile(String filePath);
  public static ImageFrame createWithRGBA(ByteBuffer data, int width, int height, int stride);
  public static ImageFrame createWithBGRA(ByteBuffer data, int width, int height, int stride);
  public static ImageFrame createWithI420(int width, int height, ByteBuffer yBuffer, int strideY,
      ByteBuffer uBuffer, int strideU, ByteBuffer vBuffer, int strideV);
  public static ImageFrame createWithAndroid420(int width, int height, ByteBuffer yBuffer,
      int strideY, ByteBuffer uBuffer, int strideU, ByteBuffer vBuffer, int strideV,
      int pixelStrideUV);
  
  public int rotate(ImageBuffer.Rotation rotation);
  public boolean isValid();
  
  public ImageBuffer toRGBA();
  public ImageBuffer toBGRA();
  public ImageBuffer toRGB();
  public ImageBuffer toBGR();
  public ImageBuffer toI420();
  public ImageBuffer toNV12();
  public ImageBuffer toNV21();
  
  public void release();
}

ImageBuffer

Image buffer class for accessing image data.

Supported Image Formats:

  • I420: YUV 4:2:0 (3 planes, Y, U, V)
  • NV12: YUV 4:2:0 (2 planes, Y + UV)
  • NV21: YUV 4:2:0 (2 planes, Y + VU, Android default format)
  • RGBA, BGRA: 32-bit RGBA/BGRA
  • RGB, BGR: 24-bit RGB/BGR
  • Texture: Texture format

Image Rotation Angles:

  • ROTATION_0: 0 degrees
  • ROTATION_90: Clockwise 90 degrees
  • ROTATION_180: Clockwise 180 degrees
  • ROTATION_270: Clockwise 270 degrees

Property Access:

  • getWidth(), getHeight(): Get image width and height
  • getSize(): Get image data size (in bytes)
  • getStride(): Get image stride
  • getFormat(): Get image format

Data Access:

  • getData(): Get raw image data (ByteBuffer)
  • YUV format specific: getDataY(), getDataU(), getDataV(), getDataUV()
  • YUV format strides: getStrideY(), getStrideU(), getStrideV(), getStrideUV()

Resource Management:

  • isValid(): Check if buffer is valid
  • release(): Release native resources
java
public enum Format {
  I420(0),     // YUV 4:2:0 12bpp (3 planes, Y, U, V)
  NV12(1),     // YUV 4:2:0 12bpp (2 planes, Y + UV)
  NV21(2),     // YUV 4:2:0 12bpp (2 planes, Y + VU, Android default)
  BGRA(3),     // BGRA 8:8:8:8 32bpp
  RGBA(4),     // RGBA 8:8:8:8 32bpp
  BGR(5),      // BGR 8:8:8 24bpp
  RGB(6),      // RGB 8:8:8 24bpp
  Texture(7);  // Texture format
}

public enum Rotation {
  ROTATION_0(0),    // 0 degrees
  ROTATION_90(1),   // Clockwise 90 degrees
  ROTATION_180(2),  // Clockwise 180 degrees
  ROTATION_270(3);  // Clockwise 270 degrees
}

public class ImageBuffer {
  public int getWidth();
  public int getHeight();
  public int getSize();
  public int getStride();
  public Format getFormat();
  
  public ByteBuffer getData();
  
  public ByteBuffer getDataY();
  public ByteBuffer getDataU();
  public ByteBuffer getDataV();
  public ByteBuffer getDataUV();
  
  public int getStrideY();
  public int getStrideU();
  public int getStrideV();
  public int getStrideUV();
  
  public boolean isValid();
  public void release();
}