当前位置:网站首页>如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
2022-07-29 04:51:00 【nginx】

处理前

处理后
功能介绍
输入一张包含一个或多个人脸(最多支持3人)的图片,检测人脸并对其进行微笑处理,基于原人脸信息实现一键微笑,生成微笑图片。
Demo演示

下面我们就一起来实操一下如何接入华为视频编辑服务,实现“一键微笑”功能:
1. 开发准备
详细准备步骤可参考华为开发者联盟官网
2.编辑工程集成
2.1 设置应用的鉴权信息
可以通过api_key或者Access Token来设置应用鉴权信息。
通过setAccessToken方法设置Access Token,在应用启动时初始化设置一次即可,无需多次设置。
通过setApiKey方法设置api_key,在应用启动时初始化设置一次即可,无需多次设置。
MediaApplication.getInstance().setAccessToken("your access token");
2.2设置唯一标识ID,即License ID。
MediaApplication.getInstance().setApiKey("your ApiKey");
License ID是进行管控的有效凭证,您要保证设置License ID的唯一性。
2.2.1初始化Editor运行环境
MediaApplication.getInstance().setLicenseId("License ID");
创建编辑工程,需要首先创建Editor对象并初始化其运行环境。当离开编辑工程时,应释放Editor实例。
(1)创建Editor对象
(2)指定预览窗口的布局位置
HuaweiVideoEditor editor = HuaweiVideoEditor.create(getApplicationContext());
预览窗口负责视频图像画面的渲染,由视频编辑原子能力SDK内部创建SurfaceView来实现。在创建窗口之前,需要在您的App中指定预览窗口的布局位置。
(3)初始化运行环境,如果License鉴权失败,会抛出LicenseException。
<LinearLayoutandroid:id="@+id/video_content_layout"android:layout_width="0dp"android:layout_height="0dp"android:background="@color/video_edit_main_bg_color"android:gravity="center"android:orientation="vertical" />// 指定预览窗口LinearLayout mSdkPreviewContainer = view.findViewById(R.id.video_content_layout);// 设置预览窗口承载的布局editor.setDisplay(mSdkPreviewContainer);
当Editor对象创建之后,此时还没有占用实际的系统资源,需要手动选择其环境初始化的时机,此时视频编辑原子能力SDK内部会创建必须的线程和定时器等。
3“一键动效”能力集成
try {editor.initEnvironment();} catch (LicenseException error) {SmartLog.e(TAG, "initEnvironment failed: " + error.getErrorMsg());finish();return;}
HMS Core视频编辑服务除了支持一键微笑,还提供基础视频编辑、AI着色、专属滤镜、精彩片段、一键染发、人物追踪、人脸隐藏等视频创作能力,开发者可依据应用场景,在App中轻松完成视频功能的集成。
// 添加一键微笑AI特效,只支持图片资源imageAsset.addFaceSmileAIEffect(new HVEAIProcessCallback() {@Overridepublic void onProgress(int progress) {// 一键微笑AI特效处理进度}@Overridepublic void onSuccess() {// 一键微笑AI特效处理成功}@Overridepublic void onError(int errorCode, String errorMessage) {// 一键微笑AI特效处理失败}});// 中断一键微笑AI特效处理imageAsset.interruptFaceSmile();// 移除一键微笑AI特效imageAsset.removeFaceSmileAIEffect();
了解更多详情>>
访问华为开发者联盟官网
获取开发指导文档
华为移动服务开源仓库地址:GitHub、Gitee
关注我们,第一时间了解 HMS Core 最新技术资讯~
边栏推荐
- 如何避免示波器电流探头损坏
- Recommendation system of online education
- Basic grammar of C language
- Actual combat of flutter - DIO of request encapsulation (II)
- IOS interview preparation - IOS
- EF core: one to one, many to many configuration
- IOS interview preparation - Objective-C
- The most comprehensive promotion plan for the launch of new products
- Traffic flow prediction pit climbing record (I): traffic flow data set, original data
- Unity Foundation (3) -- various coordinate systems in unity
猜你喜欢

网络之以太网

Torch.nn.crossentropyloss() details

Build auto.js script development environment

VScode 一键编译和调试

Climbing the pit of traffic flow prediction (II): the simplest LSTM predicts traffic flow using tensorflow2

Deep analysis of data storage in memory (Advanced C language)

Solution to the fourth game of 2022 Hangzhou Electric Multi school league

Use jupyter (2) to establish shortcuts to open jupyter and common shortcut keys of jupyter

2022杭电多校联赛第四场 题解

un7.28:redis客户端常用命令。
随机推荐
Implementation of img responsive pictures (including the usage of srcset attribute and sizes attribute, and detailed explanation of device pixel ratio)
Tower of Hanoi classic recursion problem (C language implementation)
Nail dialog text converted to pictures cannot be copied and pasted on the document
STL source code analysis (Hou Jie) notes -- Classification and testing of stl containers
[c language] PTA 7-63 falling ball
Implementation of flutter gesture monitoring and Sketchpad
def fasterrcnn_ resnet50_ FPN () instance test
After the spinning up installation is completed, use the tutorial to test whether it is successful. There are library "Glu" not found and 'from pyglet.gl import * error solutions
iOS面试准备 - 其他篇
Redux quick start
Sguard64.exe ace guard client exe: frequent disk reading and writing, game jamming, and Solutions
Traffic flow prediction pit climbing record (I): traffic flow data set, original data
mujoco和mujoco_py安装以及解决libXcursor.so.1:NO such dictionary
钉钉对话框文子转换成图片 不能复制粘贴到文档上
Recommendation system of online education
Reveal安装配置调试
[c language] PTA 7-50 output Fahrenheit Celsius temperature conversion table
def fasterrcnn_resnet50_fpn()实例测试
Learn matlab to draw geographical map, line scatter bubble density map
EF core: one to one, many to many configuration