pod 'TEBeautyKit',:path => 'TEBeautyKit/TEBeautyKit.podspec'
TEBeautyKit.h+ (void)setTELicense:(NSString *)url key:(NSString *)key completion:(callback _Nullable )completion;
[TEBeautyKit setTELicense:@"your license" key:@"your key" completion:^(NSInteger authresult, NSString * _Nullable errorMsg) {NSLog(@"----------result: %zd %@",authresult,errorMsg);}];
TEBeautyConfig.h/**beauty: Beauty json pathbeautyBody: Body shaping json pathlut: Filters json pathmotion: Animated effects json pathmakeup: Makeup json pathsegmentation: Background segmentation json path*/-(void)setTEPanelViewRes:(NSString *)beauty beautyBody:(NSString *)beautyBody lut:(NSString *)lut motion:(NSString *)motion makeup:(NSString *)makeup segmentation:(NSString *)segmentation;
- (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"]];}
-(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);}];
//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;
-(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];}];}
/**textureId: Texture IDtextureWidth: Texture widthtextureHeight: Texture heightorigin: Enumeration value (YtLightImageOriginTopLeft, YtLightImageOriginBottomLeft). When setting to YtLightImageOriginBottomLeft, the image is flipped verticallyorientation: Enumeration value for image rotation angle*/- (YTProcessOutput *)processTexture:(int)textureIdtextureWidth:(int)textureWidthtextureHeight:(int)textureHeightwithOrigin:(YtLightImageOrigin)originwithOrientation:(YtLightDeviceCameraOrientation)orientation
#pragma mark - TRTCVideoFrameDelegate- (uint32_t)onProcessVideoFrame:(TRTCVideoFrame *_Nonnull)srcFrame dstFrame:(TRTCVideoFrame *_Nonnull)dstFrame {if(!_xMagicKit){[self initXMagic];}YTProcessOutput *output = [self.teBeautyKit processTexture:srcFrame.textureIdtextureWidth:srcFrame.width textureHeight:srcFrame.heightwithOrigin:YtLightImageOriginTopLeft withOrientation:YtLightCameraRotation0];dstFrame.textureId = output.textureData.texture;return 0;}
- (void)destroyXMagic{[self.xMagicKit clearListeners];[self.xMagicKit deinit];self.xMagicKit = nil;}
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 |
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. |
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.//Create TEBeautyKit object, do not enable the High Performance Mode+ (void)create:(OnInitListener _Nullable )onInitListener;/**Create TEBeautyKit objectisEnableHighPerformance: Whether to enable the High Performance ModeWhen 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 removal2. Eyebrows: Angle, distance, height, length, thickness, eyebrow peak3. Lips: Smile lip4. 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)inputImageimageWidth:(int)imageWidthimageHeight:(int)imageHeightneedReset:(bool)needReset;// Processing texture- (YTProcessOutput *_Nullable)processTexture:(int)textureIdtextureWidth:(int)textureWidthtextureHeight:(int)textureHeightwithOrigin:(YtLightImageOrigin)originwithOrientation:(YtLightDeviceCameraOrientation)orientation;// Processing CVPixelBufferRef- (YTProcessOutput * _Nullable)processPixelData:(CVPixelBufferRef _Nullable )pixelDatapixelDataWidth:(int)pixelDataWidthpixelDataHeight:(int)pixelDataHeightwithOrigin:(YtLightImageOrigin)originwithOrientation:(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;
// 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 parametersbeauty: Effect json pathbeautyBody: Body shaping json pathlut: Filter json pathmotion: Animated effects json pathmakeup: Makeup json pathsegmentation: Background segmentation json path*/-(void)setTEPanelViewRes:(NSString *)beautybeautyBody:(NSString *)beautyBodylut:(NSString *)lutmotion:(NSString *)motionmakeup:(NSString *)makeupsegmentation:(NSString *)segmentation;
// 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
Was this page helpful?