iOS

功能说明

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

iOS 集成指引

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。{&quot;eyeBlinkLeft&quot;,&quot;eyeLookDownLeft&quot;,&quot;eyeLookInLeft&quot;,&quot;eyeLookOutLeft&quot;,&quot;eyeLookUpLeft&quot;,&quot;eyeSquintLeft&quot;,&quot;eyeWideLeft&quot;,&quot;eyeBlinkRight&quot;,&quot;eyeLookDownRight&quot;,&quot;eyeLookInRight&quot;,&quot;eyeLookOutRight&quot;,&quot;eyeLookUpRight&quot;,&quot;eyeSquintRight&quot;,&quot;eyeWideRight&quot;,&quot;jawForward&quot;,&quot;jawLeft&quot;,&quot;jawRight&quot;,&quot;jawOpen&quot;,&quot;mouthClose&quot;,&quot;mouthFunnel&quot;,&quot;mouthPucker&quot;,&quot;mouthRight&quot;,&quot;mouthLeft&quot;,&quot;mouthSmileLeft&quot;,&quot;mouthSmileRight&quot;,&quot;mouthFrownRight&quot;,&quot;mouthFrownLeft&quot;,&quot;mouthDimpleLeft&quot;,&quot;mouthDimpleRight&quot;,&quot;mouthStretchLeft&quot;,&quot;mouthStretchRight&quot;,&quot;mouthRollLower&quot;,&quot;mouthRollUpper&quot;,&quot;mouthShrugLower&quot;,&quot;mouthShrugUpper&quot;,&quot;mouthPressLeft&quot;,&quot;mouthPressRight&quot;,&quot;mouthLowerDownLeft&quot;,&quot;mouthLowerDownRight&quot;,&quot;mouthUpperUpLeft&quot;,&quot;mouthUpperUpRight&quot;,&quot;browDownLeft&quot;,&quot;browDownRight&quot;,&quot;browInnerUp&quot;,&quot;browOuterUpLeft&quot;,&quot;browOuterUpRight&quot;,&quot;cheekPuff&quot;,&quot;cheekSquintLeft&quot;,&quot;cheekSquintRight&quot;,&quot;noseSneerLeft&quot;,&quot;noseSneerRight&quot;,&quot;tongueOut&quot;}
其他字段是 人脸信息,只有当您购买了相关 License 才有那些字段。如果您只想获取表情数据,请忽略那些字段。