功能说明
输入一张包含人脸的照片,输出人物面部特征信息,包括眼睛、眉毛、发型、肤色、性别、年龄等。该接口需要联网,SDK会把照片上传到Server端进行解析。
集成指引
接口说明
XMagicApi.java
public void getFaceFeatureFromPhoto(Bitmap bitmap, FaceFeatureListener listener);
参数 bitmap:请尽量让人脸位于画面中间,建议画面中只包含一个人脸,如果有多个人脸,SDK会随机选择一个。建议照片的短边大于等于500px,尺寸过小会影响识别效果。
参数 FaceFeatureListener,返回识别的结果
public interface FaceFeatureListener {
void onError(int errCode, String msg);
void onFinish(FaceDetailAttributesInfo faceInfo);
}
onError 回调:解析失败时会回调此接口,错误码如下。
public static final int ERROR_NO_AUTH = 1;
public static final int ERROR_RES_INVALID = 5;
public static final int ERROR_PHOTO_INVALID = 10;
public static final int ERROR_NETWORK_REQUEST_FAILED = 20;
public static final int ERROR_DATA_PARSE_FAILED = 30;
public static final int ERROR_ANALYZE_FAILED = 40;
public static final int ERROR_AVATAR_SOURCE_DATA_EMPTY = 50;
onFinish 回调:解析成功时回调此接口,FaceDetailAttributesInfo 说明如下。
public static class FaceDetailAttributesInfo {
public int age;
public int emotion;
public Eye eye;
public Eyebrow eyebrow;
public int gender;
public Hair hair;
public Hat hat;
public int mask;
public int moustache;
public int nose;
public int shape;
public int skin;
public int smile;
}
public static class Eye {
public int eyelidType;
public int eyeSize;
public int glass;
public int eyeOpen;
}
public static class Eyebrow {
public int eyebrowLength;
public int eyebrowDensity;
public int eyebrowCurve;
}
public static class Hair {
public int length;
public int bang;
public int color;
}
public static class Hat {
public int style;
public int color;
}
本页内容是否解决了您的问题?