当前位置:网站首页>如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
2022-07-28 13:43:00 【HMS Core】
最近一键“露齿笑”席卷全网,无论是短视频用户还是社交App用户都在使用这项黑科技。当三两好友聚会拍集体照留念时,为了处理个别人的表情“瑕疵”,让大家都尽量保持微笑,总要进行表情微调,但如果需要进行复杂的换头换脸等P图操作,对用户来说门槛太高。有些用户“镜头恐惧”,拍照时不会微笑、表情尴尬;有些用户对自己牙齿不自信,不敢拍照露齿笑。而现在,华为HMS Core视频编辑服务“一键微笑”功能可以很好解决用户的需求,能够自动检测照片中的人像,对表情进行修改,从而提升开心程度;可将检测到的人像由不笑到抿嘴微笑,也可张嘴露齿微笑,微笑自然且不会改变原本人脸的合理结构。

处理前

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

下面我们就一起来实操一下如何接入华为视频编辑服务,实现“一键微笑”功能:
1. 开发准备
详细准备步骤可参考华为开发者联盟官网
2. 编辑工程集成
2.1 设置应用的鉴权信息
可以通过api_key或者Access Token来设置应用鉴权信息。
通过setAccessToken方法设置Access Token,在应用启动时初始化设置一次即可,无需多次设置。
MediaApplication.getInstance().setAccessToken("your access token");通过setApiKey方法设置api_key,在应用启动时初始化设置一次即可,无需多次设置。
MediaApplication.getInstance().setApiKey("your ApiKey");2.2设置唯一标识ID,即License ID。
License ID是进行管控的有效凭证,您要保证设置License ID的唯一性。
MediaApplication.getInstance().setLicenseId("License ID");2.2.1初始化Editor运行环境
创建编辑工程,需要首先创建Editor对象并初始化其运行环境。当离开编辑工程时,应释放Editor实例。
(1) 创建Editor对象
HuaweiVideoEditor editor = HuaweiVideoEditor.create(getApplicationContext());(2) 指定预览窗口的布局位置
预览窗口负责视频图像画面的渲染,由视频编辑原子能力SDK内部创建SurfaceView来实现。在创建窗口之前,需要在您的App中指定预览窗口的布局位置。
<LinearLayout android: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);(3) 初始化运行环境,如果License鉴权失败,会抛出LicenseException。
当Editor对象创建之后,此时还没有占用实际的系统资源,需要手动选择其环境初始化的时机,此时视频编辑原子能力SDK内部会创建必须的线程和定时器等。
try { editor.initEnvironment(); } catch (LicenseException error) { SmartLog.e(TAG, "initEnvironment failed: " + error.getErrorMsg()); finish(); return; }3 “一键动效”能力集成
// 添加一键微笑AI特效,只支持图片资源imageAsset.addFaceSmileAIEffect(new HVEAIProcessCallback() { @Override public void onProgress(int progress) { // 一键微笑AI特效处理进度 } @Override public void onSuccess() { // 一键微笑AI特效处理成功 } @Override public void onError(int errorCode, String errorMessage) { // 一键微笑AI特效处理失败 }});// 中断一键微笑AI特效处理imageAsset.interruptFaceSmile();// 移除一键微笑AI特效imageAsset.removeFaceSmileAIEffect();HMS Core视频编辑服务除了支持一键微笑,还提供基础视频编辑、AI着色、专属滤镜、精彩片段、一键染发、人物追踪、人脸隐藏等视频创作能力,开发者可依据应用场景,在App中轻松完成视频功能的集成。
了解更多详情>>
访问华为开发者联盟官网
获取开发指导文档
华为移动服务开源仓库地址:GitHub、Gitee
关注我们,第一时间了解 HMS Core 最新技术资讯~
边栏推荐
- 力扣解法汇总1331-数组序号转换
- Xcode编写SwiftUI代码时一个编译通过但导致预览(Preview)崩溃的小陷阱
- HCIP第十一天
- Open source project - taier1.2 release, new workflow, tenant binding simplification and other functions
- Career planning of Software Test Engineer
- Detailed explanation of C language student achievement management system [easy to understand]
- Metersphere -- Open Source continuous testing platform
- Nport serial server configuration website (whether the serial server is from network port to serial port)
- Excel VBA 开发过程中遇到的一些问题,解决方案,持续更新
- Afnetworking crash course
猜你喜欢
![[server data recovery] HP StorageWorks series server RAID5 offline data recovery of two disks](/img/23/4d07adcb5fb2c3b4c5090dacd02c89.jpg)
[server data recovery] HP StorageWorks series server RAID5 offline data recovery of two disks

Career planning of Software Test Engineer

Xcode编写SwiftUI代码时一个编译通过但导致预览(Preview)崩溃的小陷阱

@DS('slave') 多数据源兼容事务问题解决方案

These three online PS tools should be tried

文件批量重命名工具Bulk Rename Utility

MiniTest--小程序自动化测试框架

Floating point data type in C language (did you learn to waste it)

【七夕】七夕孤寡小青蛙究极版?七夕节最终章!

用友BIP CRM新品发布,赋能大中型企业营销增长
随机推荐
[server data recovery] HP StorageWorks series server RAID5 offline data recovery of two disks
HCIP第十二天
Thrift 序列化协议浅析
[utils] fastdfs tool class
AFNetworking速成教程
UI开发中所遇到的各种坑
Leetcode 1331. array sequence number conversion
LeetCode 0142.环形链表 II
When Xcode writes swiftui code, it is a small trap that compiles successfully but causes the preview to crash
Clickhouse architecture and design
如何有效进行回顾会议(上)?
Install mysql5.7.36 in CentOS
手机滚动截屏软件推荐
BGP experiment
How to effectively conduct the review meeting (Part 1)?
九、uni-popup用法 下拉框底部弹窗效果
Nport serial server configuration website (whether the serial server is from network port to serial port)
数据库优化 理解这些就够了
Cv:: mat conversion to qimage error
2022低压电工考试题及答案