Android API Reference
Logging Related
Log Levels
Log level enumeration for controlling log output levels.
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 outputfileEnabled: Whether to enable file outputlevel: Log levelfileName: Log file path (only effective whenfileEnabledistrue)
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);
}Engine Related
Process Mode
Image processing mode enumeration.
IMAGE: Image mode, suitable for single image processingVIDEO: Video mode, suitable for video streams and live streaming scenarios, better performance
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 iflicenseJsonis provided)appKey: Application key (optional, not required iflicenseJsonis provided)licenseJson: License data JSON string (optional, if provided, takes priority andappIdandappKeyare not required)
Methods:
isValid(): Validate if configuration is valid- If
licenseJsonis provided, use license data verification - Otherwise, require
appIdandappKeyfor automatic online verification
- If
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 instancevoid release(): Release engine resources
Beauty Type Control
int enableBeautyType(BeautyType type, boolean enabled): Enable or disable beauty typeboolean isBeautyTypeEnabled(BeautyType type): Check if beauty type is enabledint 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:
VirtualBackgroundOptionsobject containing background mode and background image - Return value:
0indicates success,-1indicates engine not initialized,-2indicates invalid parameters (options is null or invalid)
- Parameter:
Image Processing
ImageFrame processImage(ImageFrame inputFrame, ProcessMode processMode): Process image frame
Return Value Descriptions:
- Methods return
inttype:0indicates success-1indicates engine not initialized-2indicates invalid parameters (only forsetVirtualBackgroundmethod)
processImagereturnsImageFrame: Processed image frame, returnsnullon failure
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.
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.
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.
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.
public enum MakeupParam {
LIPSTICK(0), // Lipstick
BLUSH(1); // Blush
}Virtual Background Options
Virtual background effect configuration options.
public static class VirtualBackgroundOptions {
public BackgroundMode mode = BackgroundMode.NONE;
public ImageFrame backgroundImage = null;
public VirtualBackgroundOptions() {}
public VirtualBackgroundOptions(BackgroundMode mode) {
this.mode = mode;
}
}Image Related
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 datacreateWithBGRA(ByteBuffer data, int width, int height, int stride): Create from BGRA datacreateWithI420(...): Create from I420 YUV datacreateWithAndroid420(...): 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 formatstoI420(),toNV12(),toNV21(): Convert to YUV formats
Resource Management:
void release(): Release native resources
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/BGRARGB,BGR: 24-bit RGB/BGRTexture: Texture format
Image Rotation Angles:
ROTATION_0: 0 degreesROTATION_90: Clockwise 90 degreesROTATION_180: Clockwise 180 degreesROTATION_270: Clockwise 270 degrees
Property Access:
getWidth(),getHeight(): Get image width and heightgetSize(): Get image data size (in bytes)getStride(): Get image stridegetFormat(): 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 validrelease(): Release native resources
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();
}