企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
MHUI 是开源的。英文界面和中文界面所用的文件名称不同,功能是一样的.菜单使用默认美颜方法如下(MHUI is open source. The English interface and the Chinese interface use different file names and have the same functions The default beauty method used in the menu is as follows:): 1) 在直播或者视频页面中添加美颜功能(Add beauty function in live broadcast or video page) ``` #import <MHBeautySDK/MHBeautyManager.h> #import "MHBeautyParams.h" #import "MHMeiyanMenusView.h" (EnglishVersion is #import "BeautyFoxMenusView.h") ``` 2) 声明属性 ``` @property(nonatomic, strong)MHMeiyanMenusView *menusV iew; (@property (nonatomic, strong) BeautyFoxMenusView *menusView;) @property(nonatomic, strong)MHBeautyManager *beautyMana ger; ``` 3) 初始化美颜管理器(Initialize Beauty Manager) \- (MHBeautyManager \*)beautyManager { if (!\_beautyManager) { \_beautyManager = \[\[MHBeautyManager alloc\] init\]; \_beautyManager.maxFace = 3; } return \_beautyManager; } 4) 初始化美颜菜单(Initialize beauty menu) /// 初始化美颜菜单(推荐使用) /// @param frame frame /// @param superView 所要添加到的视图 /// @param manager 美颜管理器,完成初始化后传入 /// 该方法默认使用美狐相关功能,不需要实现MHMeiyanMenusViewDelegate中的美颜方法 \- (instancetype)initWithFrame:(CGRect)frame superView:(UIView \*)superView beautyManager:(MHBeautyManager \*)manager; EnhlisjVersion: ///(Initialize beauty menu,Recommand to use) /// @param frame frame /// @param superView /// @param manager Pass in after initialization /// This method uses the relevant functions of Meihu by default \- (instancetype)initWithFrame:(CGRect)frame superView:(UIView \*)superView beautyManager:(MHBeautyManager \*)manager; 5) 初始化美颜菜单页实例(Initialize beauty menu page instance) \- (MHMeiyanMenusView \*)menusView { if (!\_menusView) { \_menusView = \[\[MHMeiyanMenusView alloc\] initWithFrame:CGRectMake(0, window\_height - MHMeiyanMenuHeight - BottomIndicatorHeight, window\_width, MHMeiyanMenuHeight) superView:self.view beautyManager:self.beautyManager\]; } return \_menusView; } 6) 如果需要实现代理方法,则遵循协议MHMeiyanMenusViewDelegate , (BeautyFoxMenusViewDelegate) 7) 展示美颜页面,(Show beauty page): \[self.menusView showMenuView:YES\]; 8) 美颜菜单的隐藏,则可以在控制器的 touchesBegan 方法中调用上面的方法。示例代码(the beauty menu can be hidden in the touchesbegan of the controller The above method is invoked in the method. Sample code): \- (void)touchesBegan:(NSSet<UITouch \*> \*)touches withEvent:(UIEvent \*)event{ if (self.menusView.isShow) { \[self.menusView showMenuView:NO\]; if (!\[self.menusView isDescendantOfView:self.view\]) { //页面上其他控件显示,根据自己的项目完善 } } } 9) 如果不想隐藏美颜菜单,可以在 touchesBegan 方法中调用 (If you don't want to hide the beauty menu, you can call it in the touchesBegan method.) \[self.menusView showMenuView:YES\]; 如果项目中有需求是调用保存的美颜效果,调用下面的方法。详情请看 MHMeiyanMenusView.m(If the demand in the project is to call the saved beauty effect, call the following method. For details, please see MHMeiyanMenusView.m) -(void)setupDefaultBeautyAndFaceValue; 在渲染方法中调用,要设置标志符保证该方法只走一次,不 然耗内存,(In the rendering method, we need to set the identifier to ensure that the method will go only once. Ran out of memory): \- (GLuint)onPreProcessTexture:(GLuint)texture width:(CGFloat)width height:(CGFloat)height { \[self.beautyManager processWithTexture:texture width:width height:height\]; if (!self.isSetDefaultValue) { \[self.menusView setupDefaultBeautyAndFaceValue\]; self.isSetDefaultValue = YES; } return texture; } 10) 渲染结束,要释放渲染资源,否则会造成内存泄漏(At the end of rendering, the rendering resources should be released, otherwise it will cause memory leakage) \- (void)dealloc { if (\_beautyManager) { \[\_beautyManager destroy\]; \_beautyManager = nil; } } 以下是不同厂商的直播/短视频 SDK 的调用渲染方法(The following is the call rendering method of live / short video SDKs from different manufacturers):