please select
Beauty AR
  • Overview
  • Web
    • Quick Start
    • Integration
      • Overview
      • Built-in Camera
      • Custom Stream
      • Loading Optimization
      • Configuring Effects
      • Configuring Segmentation
      • Configuring Animojis and Virtual Avatars
    • API Document
    • Release Notes
    • Best Practices
      • Publishing over WebRTC
      • Publishing over WebRTC (Preinitialization)
      • Publishing Using TRTC
    • FAQs
  • Android
    • Integration
      • Integrating SDK
      • Integrating TEBeautyKit
    • API Document
    • Release Notes
    • Best Practices
      • Reducing SDK Size
      • Effect Parameters
    • Advanced Capabilities
      • Gesture Recognition
      • Face Recognition
      • Virtual Background
    • Material Production
      • Beauty AR Studio Introduction
    • FAQs
  • IOS
    • Integration
      • Integrating SDK
      • Integrating TEBeautyKit
    • API Document
    • Release Notes
    • Best Practices
      • Reducing SDK Size
      • Effect Parameters
    • Advanced Capabilities
      • Gesture Recognition
      • Face Recognition
      • Virtual Background
    • Material Production
      • Beauty AR Studio Introduction
    • FAQs
  • Flutter
    • Integration
    • API Document
    • Material Production
      • Beauty AR Studio Introduction
  • Overview
    • Overview
  • Activate the Service
  • Pricing
  • Free Trial
    • Web
    • Mobile
Beauty AR

Integrating TEBeautyKit

Features

TEBeautyKit is the UI panel library for the Beauty AR module, used for quick and convenient usage and management of the effect features. You can download the TEBeautyDemo from Github. The effect is as shown in the figure below:




Integration Guide

1. Download and unzip TEBeautyKit.
2. Copy the TEBeautyKit folder into your project and make it the same level as the podfile directory.
3. Edit the podfile, adding the following code:
pod 'TEBeautyKit',:path => 'TEBeautyKit/TEBeautyKit.podspec'

Use Guide

1. Effect Authentication
After the app is launched, effect authentication needs to be performed once to use the effect feature normally.
API:
TEBeautyKit.h
+ (void)setTELicense:(NSString *)url key:(NSString *)key completion:(callback _Nullable )completion;
Example:
[TEBeautyKit setTELicense:@"your license" key:@"your key" completion:^(NSInteger authresult, NSString * _Nullable errorMsg) {
NSLog(@"----------result: %zd %@",authresult,errorMsg);
}];
2. Set the Effect Material Path
The effect data on the effect panel are all parsed from the json file in the material path set here.
API:
TEBeautyConfig.h
/**
beauty: Beauty json path
beautyBody: Body shaping json path
lut: Filters json path
motion: Animated effects json path
makeup: Makeup json path
segmentation: Background segmentation json path
*/
-(void)setTEPanelViewRes:(NSString *)beauty beautyBody:(NSString *)beautyBody lut:(NSString *)lut motion:(NSString *)motion makeup:(NSString *)makeup segmentation:(NSString *)segmentation;
Example:
- (void)initBeautyJson{
NSString *resourcePath = [[NSBundle mainBundle]
pathForResource:@"TEBeautyKitResources" ofType:@"bundle"];
NSBundle *bundle = [NSBundle bundleWithPath:resourcePath];
[[TEUIConfig shareInstance] setTEPanelViewRes:[bundle pathForResource:@"beauty_S1" ofType:@"json"]
beautyBody:[bundle pathForResource:@"beauty_body" ofType:@"json"]
lut:[bundle pathForResource:@"lut" ofType:@"json"]
motion:[bundle pathForResource:@"motions" ofType:@"json"]
makeup:[bundle pathForResource:@"makeup" ofType:@"json"]
segmentation:[bundle pathForResource:@"segmentation" ofType:@"json"]];
}
3. Initialize and add TEPanelView
-(TEPanelView *)tePanelView{
if (!_tePanelView) {
_tePanelView = [[TEPanelView alloc] init:nil comboType:nil];
_tePanelView.delegate = self;
}
return _tePanelView;
}
[self.view addSubview:self.tePanelView];
[self.tePanelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.view);
make.centerX.mas_equalTo(self.view);
make.height.mas_equalTo(250);
make.bottom.mas_equalTo(self.view.mas_bottom);
}];
4. Create an effect object
API:

//Create the TEBeautyKit object, do not enable the High Performance Mode
+ (void)create:(OnInitListener _Nullable )onInitListener;
//Create TEBeautyKit object, isEnableHighPerformance: Whether to enable the High Performance Mode
+ (void)create:(BOOL)isEnableHighPerformance onInitListener:(OnInitListener _Nullable )onInitListener;

Example:
-(void)initXMagic{
__weak __typeof(self)weakSelf = self;
[TEBeautyKit create:^(XMagic * _Nullable api) {
__strong typeof(self) strongSelf = weakSelf;
strongSelf.xMagicKit = api;
[strongSelf.teBeautyKit setXMagicApi:api];
strongSelf.tePanelView.teBeautyKit = strongSelf.teBeautyKit;
[strongSelf.teBeautyKit setTePanelView:strongSelf.tePanelView];
[strongSelf.teBeautyKit setLogLevel:YT_SDK_ERROR_LEVEL];
strongSelf.tePanelView.beautyKitApi = api;
[strongSelf.xMagicKit registerSDKEventListener:strongSelf];
}];
}
5. Processing video data
API:
/**
textureId: Texture ID
textureWidth: Texture width
textureHeight: Texture height
origin: Enumeration value (YtLightImageOriginTopLeft, YtLightImageOriginBottomLeft). When setting to YtLightImageOriginBottomLeft, the image is flipped vertically
orientation: Enumeration value for image rotation angle
*/
- (YTProcessOutput *)processTexture:(int)textureId
textureWidth:(int)textureWidth
textureHeight:(int)textureHeight
withOrigin:(YtLightImageOrigin)origin
withOrientation:(YtLightDeviceCameraOrientation)orientation

Example:
#pragma mark - TRTCVideoFrameDelegate
- (uint32_t)onProcessVideoFrame:(TRTCVideoFrame *_Nonnull)srcFrame dstFrame:(TRTCVideoFrame *_Nonnull)dstFrame {
if(!_xMagicKit){
[self initXMagic];
}
YTProcessOutput *output = [self.teBeautyKit processTexture:srcFrame.textureId
textureWidth:srcFrame.width textureHeight:srcFrame.height
withOrigin:YtLightImageOriginTopLeft withOrientation:YtLightCameraRotation0];
dstFrame.textureId = output.textureData.texture;
return 0;
}
6. Destroy effect
- (void)destroyXMagic{
[self.xMagicKit clearListeners];
[self.xMagicKit deinit];
self.xMagicKit = nil;
}

Appendix

Panel JSON File Description

Beauty, Body Shaping.

Field
Description
displayName
Chinese Name
displayNameEn
English Name
icon
Image address, supports setting local images and network images. Local images support assets resources and SD resources. Assets images are as shown in the image above. For SD card images, set the full path of the image. For network images, set the corresponding HTTP link.
sdkParam
The effect SDK requires four properties. Refer to the Effect Parameters table
effectName
Effect attribute key, refer to the Effect Parameters table
effectValue
Setting the attribute intensity, refer to the Effect Parameters table
resourcePath
Setting the resource path, refer to the Effect Parameters table
extraInfo
Setting other information, refer to the Effect Parameters table
Filters, Animated Stickers and Segmentation.

Since the configuration of Filters, Animated Stickers and Segmentation is primarily identical, the JSON for filters is used here for illustration. The fields downloadPath and resourceUri are added here.
Field
Description
downloadPath
If your filter material is downloaded from the network, then the configuration here is the location of your material stored locally after download, which is a relative path, and the full path is set in TEDownloader.h using basicPath+the path set here
resourceUri
If your material needs to be downloaded via network, configure the network address here, as in the third red box in the image above. However, if your filter material is local, configure the corresponding local address according to the figure above.
Makeup

In the Makeup, the makeupLutStrength field is added under extraInfo. This field is used to adjust the strength of the filter in the makeup material (if this makeup material supports adjusting the filter strength, configure it accordingly). This field can be referenced in the Effect Parameters table.

TEBeautyKit Method Descriptions

//Create TEBeautyKit object, do not enable the High Performance Mode
+ (void)create:(OnInitListener _Nullable )onInitListener;
/**
Create TEBeautyKit object
isEnableHighPerformance: Whether to enable the High Performance Mode
When the High Performance Mode is enabled, the effect feature consumes fewer system CPU/GPU resources, reducing heating and lagging of the phone, making it more suitable for prolonged use on low-end devices.
Note: After enabling the High Performance Mode, the following effect options will be unavailable:
1. Eyes: Eye width, eye height, eye bag removal
2. Eyebrows: Angle, distance, height, length, thickness, eyebrow peak
3. Lips: Smile lip
4. Face: Slim face (natural, woman, man), chin tuck, wrinkle removal, smile lines removal. It is recommended to use "Face Shape" for comprehensive big eyes and slim face effect
*/
+ (void)create:(BOOL)isEnableHighPerformance onInitListener:(OnInitListener _Nullable )onInitListener;
// Effect Authentication
+ (void)setTELicense:(NSString *)url key:(NSString *)key completion:(callback _Nullable )completion;
// Setting effect object
- (void)setXMagicApi:(XMagic *_Nullable)xmagicApi;
// Setting effect panel, to implement the delegate of tePanelView
- (void)setTePanelView:(id)tePanelView;
// Mute Effect
- (void)setMute:(BOOL)isMute;
/** * Set the toggle of a certain feature * * @param featureName Values see XmagicConstant.FeatureName * @param enable true indicates enable, false indicates disable */
- (void)setFeatureEnableDisable:(NSString *_Nullable)featureName enable:(BOOL)enable;
// Processing image beautification
- (UIImage *_Nullable)processUIImage:(UIImage *_Nullable)inputImage
imageWidth:(int)imageWidth
imageHeight:(int)imageHeight
needReset:(bool)needReset;
// Processing texture
- (YTProcessOutput *_Nullable)processTexture:(int)textureId
textureWidth:(int)textureWidth
textureHeight:(int)textureHeight
withOrigin:(YtLightImageOrigin)origin
withOrientation:(YtLightDeviceCameraOrientation)orientation;
// Processing CVPixelBufferRef
- (YTProcessOutput * _Nullable)processPixelData:(CVPixelBufferRef _Nullable )pixelData
pixelDataWidth:(int)pixelDataWidth
pixelDataHeight:(int)pixelDataHeight
withOrigin:(YtLightImageOrigin)origin
withOrientation:(YtLightDeviceCameraOrientation)orientation;
// Set effect
- (void)setEffect:(TESDKParam *_Nullable)sdkParam;
// Setting effect list
- (void)setEffectList:(NSArray<TESDKParam *>*_Nullable)sdkParamList;
// Whether to enable the Enhanced Mode
- (void)enableEnhancedMode:(BOOL)enable;
// Access the current effect parameters
- (NSString *_Nullable)exportInUseSDKParam;
// Access saved effect parameters. Upon re-entering the Effect mode, calling setEffectList will restore the same effects.
- (NSMutableArray<TESDKParam *> *_Nonnull)getInUseSDKParamList;
// Restore the effect
- (void)onResume;
// Pause the effect
- (void)onPause;
// Destroy the effect
- (void)onDestroy;
// Access current texture image
- (void)exportCurrentTexture:(void (^_Nullable)(UIImage * _Nullable image))callback;
// Set the log
- (void)setLogLevel:(YtSDKLoggerLevel)level;
// Set AIDataListener
- (void)setAIDataListener:(id<TEBeautyKitAIDataListener> _Nullable)listener;
// Set TipsListener
- (void)setTipsListener:(id<TEBeautyKitTipsListener> _Nullable)listener;
// Save the effect parameters
- (void)saveEffectParam:(TESDKParam *_Nonnull)sdkParam;
// Delete a saved effect data
- (void)deleteEffectParam:(TESDKParam *_Nonnull)sdkParam;
// Clear saved effect parameters
- (void)clearEffectParam;

TEUIConfig Descriptions

// Color of the following properties can be modified externally
// Background color of the effect panel
@property(nonatomic,strong)UIColor *panelBackgroundColor;
// Dividing line color
@property(nonatomic,strong)UIColor *panelDividerColor;
// Selected item color
@property(nonatomic,strong)UIColor *panelItemCheckedColor;
// Text color
@property(nonatomic,strong)UIColor *textColor;
// Selected text color
@property(nonatomic,strong)UIColor *textCheckedColor;
// Progress bar color
@property(nonatomic,strong)UIColor *seekBarProgressColor;


/**
configure the effect parameters
beauty: Effect json path
beautyBody: Body shaping json path
lut: Filter json path
motion: Animated effects json path
makeup: Makeup json path
segmentation: Background segmentation json path
*/
-(void)setTEPanelViewRes:(NSString *)beauty
beautyBody:(NSString *)beautyBody
lut:(NSString *)lut
motion:(NSString *)motion
makeup:(NSString *)makeup
segmentation:(NSString *)segmentation;

TEPanelView Description

// Initialize the effect panel, fill in nil for abilityType and comboType.
- (instancetype)init:(NSString *)abilityType comboType:(NSString *)comboType;

@protocol TEPanelViewDelegate <NSObject>
// Callback after setting the effect
- (void)setEffect;
@end