Function Description
Input a photo containing a face and output facial feature information of the person, including eyes, eyebrows, hairstyle, skin color, gender, age, etc. This interface requires internet connection, and the SDK will upload the photo to the server for parsing.
Integration Guide
Interface Description
XMagicApi.java
public void getFaceFeatureFromPhoto(Bitmap bitmap, FaceFeatureListener listener);
Parameter bitmap: Please try to make the face in the center of the picture. It is recommended that the picture only contains one face. If there are multiple faces, the SDK will randomly select one. It is recommended that the short side of the photo be greater than or equal to 500px. A small size will affect the recognition effect.
Parameter FaceFeatureListener, returns the recognition result.
public interface FaceFeatureListener {
void onError(int errCode, String msg);
void onFinish(FaceDetailAttributesInfo faceInfo);
}
onError callback: This interface will be called back when the parsing fails, and the error codes are as follows.
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 callback: This interface will be called back when the parsing is successful, and FaceDetailAttributesInfo is explained as follows.
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;
}
Was this page helpful?