iOS API Reference
Logging Related
Log Levels
Log level enumeration for controlling log output levels.
typedef NS_ENUM(NSInteger, FBLogLevel) {
FBLogLevel_Trace = 0,
FBLogLevel_Debug,
FBLogLevel_Info,
FBLogLevel_Warn,
FBLogLevel_Error,
FBLogLevel_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 whenfileEnabledisYES)
FB_OBJC_API @interface FBLogConfig : NSObject
@property(nonatomic, assign) BOOL consoleEnabled;
@property(nonatomic, assign) BOOL fileEnabled;
@property(nonatomic, assign) FBLogLevel level;
@property(nonatomic, copy, nullable) NSString* fileName;
- (instancetype)init;
@endEngine Related
Process Mode
Image processing mode enumeration.
FBProcessModeImage: Image mode, suitable for single image processingFBProcessModeVideo: Video mode, suitable for video streams and live streaming scenarios, better performance
typedef NS_ENUM(NSInteger, FBProcessMode) {
FBProcessModeImage = 0, // Image mode
FBProcessModeVideo = 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)
Verification Priority:
- If
licenseJsonis not empty, use license data verification (supports online response and offline license) - Otherwise, use
appIdandappKeyfor automatic online verification
FB_OBJC_API @interface FBEngineConfig : NSObject
@property(nonatomic, copy) NSString* appId;
@property(nonatomic, copy) NSString* appKey;
@property(nonatomic, copy, nullable) NSString* licenseJson; // License data JSON string (optional)
- (instancetype)init;
@endEngine Interface
Main beauty effect engine class providing entry point for beauty functionality.
Static Methods:
setLogConfig:: Set log configuration
Instance Methods:
Beauty Type Control
setBeautyTypeEnabled:enabled:: Enable or disable beauty typeisBeautyTypeEnabled:: Check if beauty type is enableddisableAllBeautyTypes: Disable all beauty types
Parameter Settings
setBasicParam:floatValue:: Set basic beauty parameters (range 0.0 - 1.0)setReshapeParam:floatValue:: Set face reshape parameters (range 0.0 - 1.0)setMakeupParam:floatValue:: Set makeup parameters (range 0.0 - 1.0)setVirtualBackground:: Set virtual background- Parameter:
FBVirtualBackgroundOptionsobject containing background mode and background image
- Parameter:
Image Processing
processImage:processMode:: Process image frame
Return Value Descriptions:
- Methods return
inttype:0indicates success, other values indicate error codes processImage:processMode:returnsFBImageFrame: Processed image frame, returnsnilon failure
FB_OBJC_API @interface FBBeautyEffectEngine : NSObject
+ (int)setLogConfig:(FBLogConfig*)config;
+ (instancetype)createEngineWithConfig:(FBEngineConfig*)config;
- (int)setBeautyTypeEnabled:(FBBeautyType)type enabled:(BOOL)enabled;
- (BOOL)isBeautyTypeEnabled:(FBBeautyType)type;
- (int)disableAllBeautyTypes;
- (int)setBasicParam:(FBBasicParam)param floatValue:(float)value;
- (int)setReshapeParam:(FBReshapeParam)param floatValue:(float)value;
- (int)setMakeupParam:(FBMakeupParam)param floatValue:(float)value;
- (int)setVirtualBackground:(FBVirtualBackgroundOptions*)options;
- (FBImageFrame* _Nullable)processImage:(FBImageFrame*)imageFrame
processMode:(FBProcessMode)processMode;
@endBeauty Parameters
Beauty parameter enumeration classes containing all beauty-related parameter type definitions.
Beauty Types
Define available beauty functionality types.
typedef NS_ENUM(NSInteger, FBBeautyType) {
FBBeautyType_Basic = 0, // Basic beauty
FBBeautyType_Reshape, // Face reshape
FBBeautyType_Makeup, // Makeup effects
FBBeautyType_VirtualBackground, // Virtual background
};Basic Beauty Parameters
Basic beauty effect parameter types, all parameter value ranges are 0.0 - 1.0.
typedef NS_ENUM(NSInteger, FBBasicParam) {
FBBasicParam_Smoothing = 0, // Smoothing
FBBasicParam_Sharpening, // Sharpening
FBBasicParam_Whitening, // Whitening
FBBasicParam_Rosiness, // Rosiness
};Face Reshape Parameters
Face reshape effect parameter types, all parameter value ranges are 0.0 - 1.0.
typedef NS_ENUM(NSInteger, FBReshapeParam) {
FBReshapeParam_FaceThin = 0, // Face thinning
FBReshapeParam_FaceVShape, // V-shaped face
FBReshapeParam_FaceNarrow, // Narrow face
FBReshapeParam_FaceShort, // Short face
FBReshapeParam_Cheekbone, // Cheekbone
FBReshapeParam_Jawbone, // Jawbone
FBReshapeParam_Chin, // Chin
FBReshapeParam_NoseSlim, // Nose slimming
FBReshapeParam_EyeSize, // Eye enlargement
FBReshapeParam_EyeDistance, // Eye distance
};Makeup Parameters
Makeup effect parameter types, all parameter value ranges are 0.0 - 1.0.
typedef NS_ENUM(NSInteger, FBMakeupParam) {
FBMakeupParam_Lipstick = 0, // Lipstick
FBMakeupParam_Blush, // Blush
};Virtual Background Options
Virtual background effect configuration options.
FB_OBJC_API @interface FBVirtualBackgroundOptions : NSObject
@property(nonatomic, assign) FBBackgroundMode mode;
@property(nonatomic, strong, nullable) FBImageFrame *backgroundImage;
- (instancetype)init;
- (instancetype)initWithMode:(FBBackgroundMode)mode;
@end;;Image Related
FBImageFrame
Image frame class for encapsulating image data and processing.
Creation Methods:
createWithFile:: Create from file (supports PNG, JPG)createWithRGBA:width:height:stride:: Create from RGBA datacreateWithBGRA:width:height:stride:: Create from BGRA datacreateWithI420:...: Create from I420 YUV datacreateWithNV12:...: Create from NV12 YUV datacreateWithNV21:...: Create from NV21 YUV data
Image Operations:
rotate:: Rotate image (returns 0 for success)
Format Conversion:
toRGBA,toBGRA,toRGB,toBGR: Convert to RGB formatstoI420,toNV12,toNV21: Convert to YUV formats
FB_OBJC_API @interface FBImageFrame : NSObject
+ (FBImageFrame *_Nullable)createWithFile:(NSString *)filePath;
+ (FBImageFrame *_Nullable)createWithRGBA:(const uint8_t *)data
width:(int)width
height:(int)height
stride:(int)stride;
+ (FBImageFrame *_Nullable)createWithBGRA:(const uint8_t *)data
width:(int)width
height:(int)height
stride:(int)stride;
+ (FBImageFrame *_Nullable)createWithI420:(int)width
height:(int)height
dataY:(const uint8_t *)dataY
strideY:(int)strideY
dataU:(const uint8_t *)dataU
strideU:(int)strideU
dataV:(const uint8_t *)dataV
strideV:(int)strideV;
+ (FBImageFrame *_Nullable)createWithNV12:(int)width
height:(int)height
dataY:(const uint8_t *)dataY
strideY:(int)strideY
dataUV:(const uint8_t *)dataUV
strideUV:(int)strideUV;
+ (FBImageFrame *_Nullable)createWithNV21:(int)width
height:(int)height
dataY:(const uint8_t *)dataY
strideY:(int)strideY
dataUV:(const uint8_t *)dataUV
strideUV:(int)strideUV;
- (int)rotate:(FBImageRotation)rotation;
- (FBImageBuffer *_Nullable)toRGBA;
- (FBImageBuffer *_Nullable)toBGRA;
- (FBImageBuffer *_Nullable)toRGB;
- (FBImageBuffer *_Nullable)toBGR;
- (FBImageBuffer *_Nullable)toI420;
- (FBImageBuffer *_Nullable)toNV12;
- (FBImageBuffer *_Nullable)toNV21;
@endFBImageBuffer
Image buffer class for accessing image data.
Supported Image Formats:
FBImageFormatI420: YUV 4:2:0 (3 planes, Y, U, V)FBImageFormatNV12: YUV 4:2:0 (2 planes, Y + UV)FBImageFormatNV21: YUV 4:2:0 (2 planes, Y + VU)FBImageFormatRGBA,FBImageFormatBGRA: 32-bit RGBA/BGRAFBImageFormatRGB,FBImageFormatBGR: 24-bit RGB/BGRFBImageFormatTexture: Texture format
Image Rotation Angles:
FBImageRotation0: 0 degreesFBImageRotation90: Clockwise 90 degreesFBImageRotation180: Clockwise 180 degreesFBImageRotation270: Clockwise 270 degrees
Property Access:
width,height: Get image width and heightsize: Get image data size (in bytes)stride: Get image stride
Data Access:
data: Get raw image data pointer- YUV format specific:
dataY,dataU,dataV,dataUV - YUV format strides:
strideY,strideU,strideV,strideUV
typedef NS_ENUM(NSInteger, FBImageFormat) {
FBImageFormatI420,
FBImageFormatNV12,
FBImageFormatNV21,
FBImageFormatBGRA,
FBImageFormatRGBA,
FBImageFormatBGR,
FBImageFormatRGB,
FBImageFormatTexture,
};
typedef NS_ENUM(NSInteger, FBImageRotation) {
FBImageRotation0, // 0 degrees
FBImageRotation90, // Clockwise 90 degrees
FBImageRotation180, // Clockwise 180 degrees
FBImageRotation270, // Clockwise 270 degrees
};
FB_OBJC_API @interface FBImageBuffer : NSObject
@property(nonatomic, assign, readonly) int32_t width;
@property(nonatomic, assign, readonly) int32_t height;
@property(nonatomic, assign, readonly) int32_t size;
@property(nonatomic, assign, readonly) int32_t stride;
- (const uint8_t *_Nullable)data;
- (const uint8_t *_Nullable)dataY;
- (const uint8_t *_Nullable)dataU;
- (const uint8_t *_Nullable)dataV;
- (const uint8_t *_Nullable)dataUV;
- (int32_t)strideY;
- (int32_t)strideU;
- (int32_t)strideV;
- (int32_t)strideUV;
@end