iOS

最近更新时间:2023-05-18 14:58:06

我的收藏

功能说明

输入相机的 openGL 纹理,实时输出人脸52表情 BlendShape 数据,遵循苹果 ARKit 规范,详情请参见 ARFaceAnchor。您可以利用这些表情数据做一进步的开发,例如传到 Unity 中驱动您的模型。

集成指引

iOS 集成 SDK 指引,具体请参见 独立集成腾讯特效

接口调用

1. 打开功能开关:
[self.beautyKit setFeatureEnableDisable:ANIMOJI_52_EXPRESSION enable:YES];
2. 设置人脸点位信息数据回调。
2.6.0及之前版本使用如下方法
//XMagic.h
- (void)registerSDKEventListener:(id<YTSDKEventListener> _Nullable)listener;

@implementation listener
- (void)onYTDataEvent:(id)event
{
NSLog(@"YTData %@", event);
}
3.0.0版本使用如下方法
//XMagic.h
- (void)registerSDKEventListener:(id<YTSDKEventListener> _Nullable)listener;

- (void)onAIEvent:(id)event
{
NSDictionary *eventDict = (NSDictionary *)event;
if (eventDict[@"ai_info"] != nil) {
NSLog(@"ai_info %@",eventDict[@"ai_info"]);
}
}
onYTDataUpdate 返回 JSON string 结构,最多返回5个人脸信息:
onAIEvent 中通过eventDict[@"ai_info"] 获取到的 JSON string 结构数据,最多返回5个人脸信息:
{
"face_info":[{
"trace_id":5,
"face_256_point":[
180.0,
112.2,
...
],
"face_256_visible":[
0.85,
...
],
"out_of_screen":true,
"left_eye_high_vis_ratio":1.0,
"right_eye_high_vis_ratio":1.0,
"left_eyebrow_high_vis_ratio":1.0,
"right_eyebrow_high_vis_ratio":1.0,
"mouth_high_vis_ratio":1.0,
"expression_weights":[
0.12,
-0.32
...
]
},
...
]
}

字段含义

trace_id:人脸 ID,连续取流过程中,ID 相同的可以认为是同一张人脸。
expression_weights:实时表情 blendshape 数据,数组长度为52,每个数值取值范围为 0到1.0。{"eyeBlinkLeft","eyeLookDownLeft","eyeLookInLeft","eyeLookOutLeft","eyeLookUpLeft","eyeSquintLeft","eyeWideLeft","eyeBlinkRight","eyeLookDownRight","eyeLookInRight","eyeLookOutRight","eyeLookUpRight","eyeSquintRight","eyeWideRight","jawForward","jawLeft","jawRight","jawOpen","mouthClose","mouthFunnel","mouthPucker","mouthRight","mouthLeft","mouthSmileLeft","mouthSmileRight","mouthFrownRight","mouthFrownLeft","mouthDimpleLeft","mouthDimpleRight","mouthStretchLeft","mouthStretchRight","mouthRollLower","mouthRollUpper","mouthShrugLower","mouthShrugUpper","mouthPressLeft","mouthPressRight","mouthLowerDownLeft","mouthLowerDownRight","mouthUpperUpLeft","mouthUpperUpRight","browDownLeft","browDownRight","browInnerUp","browOuterUpLeft","browOuterUpRight","cheekPuff","cheekSquintLeft","cheekSquintRight","noseSneerLeft","noseSneerRight","tongueOut"}
其他字段是 人脸信息,只有当您购买了相关 License 才有那些字段。如果您只想获取表情数据,请忽略那些字段。