腾讯特效SDKiOS_音视频解决方案_同尘科技

腾讯特效SDK 2年前 (2023-06-14) 浏览 106

功能说明

该接口可通过上传包含人脸的照片获取人物面部特征信息,包括眼睛、眉毛、发型、肤色、性别、年龄等。该接口需要联网环境下才可通过 SDK 把照片上传到 Server 端进行解析。

集成指引

首先需要集成腾讯特效 SDK,具体请参见 独立集成腾讯特效。

接口说明

接口所在类:XMagic.h


+ (void)getFaceFeatureFromPhoto:(UIImage * _Nullable)image success:(nullable void (^)(FaceDetailAttributesinfo *_Nullable faceInfo))success failure:(nullable void (^)(NSInteger errorCode, NSString *_Nullable msg))failure;

参数 image:请尽量让人脸位于画面中间,建议画面中只包含一个人脸。如果有多个人脸,SDK会随机选择一个。建议照片的短边大于等于500px,尺寸过小会影响识别效果。参数 success、failure:返回识别的结果。

// 成功回调,返回识别结果(nullable void (^)(FaceDetailAttributesinfo *_Nullable faceInfo))success;// 失败回调(nullable void (^)(NSInteger errorCode, NSString *_Nullable msg))failure;


failure 回调:解析失败时会回调此接口,错误码如下。


typedef NS_ENUM(NSInteger, TEAvatarErrorCode) {    TEAvatarErrorCodeNoAuth = 1,                // 没有权限    TEAvatarErrorCodeResInValid = 5,            // 传入的Avatar素材路径无效    TEAvatarErrorCodePhotoInValid = 10,         // 读取照片失败    TEAvatarErrorCodeNetReqFailed = 20,         // 网络请求失败    TEAvatarErrorCodeNetResParseFailed = 30,    // 网络返回数据解析失败    TEAvatarErrorCodeAnalyzeFailed = 40,        // 人脸分析失败    TEAvatarErrorCodeAvatarSourceEmpty = 50     // 加载Avatar源数据失败};

success 回调:解析成功时回调此接口,FaceDetailAttributesInfo 说明如下。

    /// @brief 拍照捏脸配置数据      Snapping face configuration data
// 眼睛     eye@interface Eye : NSObject/** 识别是否双眼皮。-1:没识别,0:无,1:有 Identify whether double eyelid. -1: not recognized, 0: no, 1: yes */@property (nonatomic, assign) NSInteger eyelidType;
/** 眼睛大小。-1:没识别,0:小眼睛,1:普通眼睛,2:大眼睛 eye size. -1: No recognition, 0: Small eyes, 1: Normal eyes, 2: Big eyes */@property (nonatomic, assign) NSInteger eyeSize;
/** 识别是否佩戴眼镜。-1:没识别,0:无眼镜,1:普通眼镜,2:墨镜 Identify whether glasses are worn. -1: No recognition, 0: No glasses, 1: Ordinary glasses, 2: Sunglasses */@property (nonatomic, assign) NSInteger glass;
/** 识别眼睛是否睁开。-1:没识别,0:睁开,1:闭眼 Identify if eyes are open. -1: No recognition, 0: Open, 1: Closed eyes */@property (nonatomic, assign) NSInteger eyeOpen;@end

// 眉毛     Eyebrow@interface Eyebrow : NSObject/** 眉毛长短。0:短眉毛,1:长眉毛 The length of the eyebrows. 0: short eyebrows, 1: long eyebrows */@property (nonatomic, assign) NSInteger eyebrowLength;
/** 眉毛浓密。0:淡眉,1:浓眉 thick eyebrows. 0: light eyebrow, 1: thick eyebrow */@property (nonatomic, assign) NSInteger eyebrowDensith;
/** 眉毛弯曲。0:不弯,1:弯眉 The eyebrows are curved. 0: not curved, 1: curved eyebrow */@property (nonatomic, assign) NSInteger eyebrowCurve;@end

// 头发     Hair@interface Hair : NSObject/** 头发长度信息。0:光头,1:短发,2:中发,3:长发,4:绑发 Hair length information. 0: bald, 1: short hair, 2: medium hair, 3: long hair, 4: tied hair */@property (nonatomic, assign) NSInteger length;
/** 刘海信息。0:无刘海,1:有刘海 Bangs information. 0: no bangs, 1: with bangs */@property (nonatomic, assign) NSInteger bang;
/** 头发颜色信息。0:黑色,1:金色,2:棕色,3:灰白色 Hair color information. 0: black, 1: gold, 2: brown, 3: off-white */@property (nonatomic, assign) NSInteger color;@end

// 帽子     Hat@interface Hat : NSObject/** 帽子佩戴状态。0:不戴帽子,1:普通帽子,2:头盔,3:保安帽子 The state of wearing the hat. 0: no hat, 1: ordinary hat, 2: helmet, 3: security hat */@property (nonatomic, assign) NSInteger style;
/** 帽子颜色。0:不戴帽子,1:红色系,2:黄色系,3:蓝色系,4:黑色系,5:灰白色系,6:混色系 hat color. 0: no hat, 1: red, 2: yellow, 3: blue, 4: black, 5: off-white, 6: mixed color */@property (nonatomic, assign) NSInteger color;@end

@interface FaceDetailAttributesinfo : NSObject
@property (nonatomic, assign) NSInteger age; // [0,100]
/** 0:自然,1:高兴,2:惊讶,3:生气,4:悲伤,5:厌恶,6:害怕 0: Natural, 1: Happy, 2: Surprised, 3: Angry, 4: Sad, 5: Disgusted, 6: Scared */@property (nonatomic, assign) NSInteger emotion;
/** 性别。-1:没识别,0:男性,1:女性 gender. -1: not identified, 0: male, 1: female */@property (nonatomic, assign) NSInteger gender;
/** 眼睛信息 eye information */@property (nonatomic, strong) Eye * _Nonnull eye;
/** 眉毛信息 eyebrow information */@property (nonatomic, strong) Eyebrow * _Nonnull eyebrow;
/** 头发信息 hair information */@property (nonatomic, strong) Hair * _Nonnull hair;
/** 帽子信息 hat information */@property (nonatomic, strong) Hat * _Nonnull hat;
/** 是否有口罩,-1:没识别,0:无,1:有 Whether there is a mask, -1: no recognition, 0: no, 1: yes */@property (nonatomic, assign) NSInteger mask;
/** 胡子信息。-1:没识别,0:无胡子,1:有胡子 Beard information. -1: no recognition, 0: no beard, 1: beard */@property (nonatomic, assign) NSInteger moustache;
/** 鼻子信息。-1:没识别,0:朝天鼻,1:鹰钩鼻,2:普通,3:圆鼻头 nose information. -1: No recognition, 0: Upturned nose, 1: Hooked nose, 2: Normal, 3: Round nose */@property (nonatomic, assign) NSInteger nose;
/** 脸型信息。-1:没识别,0:方脸,1:三角脸,2:鹅蛋脸,3:心形脸,4:圆脸 face information. -1: No recognition, 0: Square face, 1: Triangular face, 2: Oval face, 3: Heart-shaped face, 4: Round face */@property (nonatomic, assign) NSInteger shape;
/** 肤色信息。-1:没识别,0:黄色皮肤,1:棕色皮肤,2:黑色皮肤,3:白色皮肤 Skin color information. -1: not identified, 0: yellow skin, 1: brown skin, 2: black skin, 3: white skin */@property (nonatomic, assign) NSInteger skin;
/** 微笑程度。[0,100] Smile level [0,100] */@property (nonatomic, assign) NSInteger smile;@end



对音视频的解决方案有疑惑?想了解解决方案收费? 联系解决方案专家

腾讯云限时活动1折起,即将结束: 马上收藏

同尘科技为腾讯云授权服务中心,购买腾讯云享受折上折,更有现金返利:同意关联,立享优惠

阿里云解决方案也看看?: 点击对比阿里云的解决方案

- 0人点赞 -

发表点评 (0条)

not found

暂无评论,你要说点什么吗?