当前位置:网站首页>如何让照片中的人物笑起来?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 最新技术资讯~
边栏推荐
- Dasctf2022.07 empowerment competition
- ios面试准备 - 网络篇
- UE plays video in scene or UMG
- Understand the Internet giant [the war between China and Taiwan] and the development thinking of China and Taiwan
- iOS面试准备 - 其他篇
- Deep analysis of data storage in memory (Advanced C language)
- 使用近场探头和电流探头进行EMI干扰排查
- [C language] PTA 7-47 binary leading zero
- Flink+iceberg environment construction and production problem handling
- Oracle update and delete data
猜你喜欢

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

Opencv learning 1 (environment configuration)

Tower of Hanoi classic recursion problem (C language implementation)

UE plays video in scene or UMG

Classes and objects (II)

Auto.js脚本开发环境搭建

Flink+Iceberg环境搭建及生产问题处理

删除word文档中的空白页

On the use of pyscript (realizing office preview)

Un7.28: common commands of redis client.
随机推荐
Leetcode 763. partition labels divide alphabetic intervals (medium)
Implementation of flutter gesture monitoring and Sketchpad
[QT learning notes] * insert pictures in the window
Auto.js脚本开发环境搭建
【无标题】
Opencv environment construction
SGuard64.exe ACE-Guard Client EXE:造成磁盘经常读写,游戏卡顿,及解决方案
Academic | [latex] super detailed texlive2022+tex studio download installation configuration
[c language] PTA 7-63 falling ball
Simply change the picture color
(heap sort) heap sort is super detailed, I don't believe you can't (C language code implementation)
Data Lake: spark, a distributed open source processing engine
C language implementation of three chess
New year's greetings from programmers
DASCTF2022.07赋能赛
[c language] use the reverse order output of the linked list (bidirectional linked list)
Oracle insert data
Record the Niua packaging deployment project
Un7.28: common commands of redis client.
使用更灵活、更方便的罗氏线圈