β¨ Update: Our API portal is now live, offering free APIs for various AI solutions, including face recognition, liveness detection, and ID document recognition. Make sure to check it out at https://getapi.faceonlive.com and take advantage of our free offerings.
NIST FRVT Certified, Fast, Accurate, Mask-Aware Face Recognition SDK with Liveness Detection
pro1.mp4
-
Create New Project with Android Studio.
-
Place SDK library ttvface.aar into app / libs.
-
Include SDK library to app / build.gradle file.
dependencies {
...
implementation files('libs/ttvface.aar')
...
}
- Import library in code and call functions.
import com.ttv.face.FaceEngine;
...
// Set License (To obtain license, please contact us)
FaceEngine.getInstance(this).setActivation(license);
// Init with Max Detectable Face Count
FaceEngine.getInstance(this).init(8);
// Detect Face
List<FaceResult> faceInfoList = new ArrayList<>();
faceInfoList = FaceEngine.getInstance(this).detectFace(bitmap);
F_OK = 0,
F_LICENSE_KEY_ERROR = -1,
F_LICENSE_APPID_ERROR = -2,
F_LICENSE_EXPIRED = -3,
F_INIT_ERROR = -4,
Type | Name | Description |
---|---|---|
Rect | rect | Face rectangle coordinates |
int | liveness | Liveness status: 0 for spoof, 1 for real, less than 0 for unknown |
int | gender | Gender classification result |
int | mask | Mask presence: 0 for no mask, 1 for mask |
int | age | Age estimation result |
float | yaw | Yaw angle: -45 to 45 degrees |
float | roll | Roll angle: -45 to 45 degrees |
float | pitch | Pitch angle: -45 to 45 degrees |
byte[] | feature | 2056-byte facial feature data |
byte[] | faceData | Encrypted facial data |
int | orient | Face orientation: 1 for no rotation, 2 for 90Β° rotation, 3 for 270Β° rotation, 4 for 180Β° rotation |
int | faceId | Face ID in the tracking face mode |
public class FaceResult {
public Rect rect;
public int liveness;
public int gender;
public int mask;
public int age;
public float yaw;
public float roll;
public float pitch;
public byte[] feature;
public byte[] faceData;
public int orient;
public int faceId;
public FaceResult() {
}
}
int setActivation(String license)
Name | Description |
---|---|
Function | Activate SDK with license input |
Parameters | 0: license String |
Return Value | F_OK: Succeed, Failed otherwise |
import com.ttv.face.FaceEngine;
...
int activated = FaceEngine.getInstance(this).setActivation(license);
List<FaceResult> detectFace(Bitmap bitmap)
Name | Description |
---|---|
Function | Get Detection Result from Bitmap image |
Parameters | Android Bitmap format Image |
Return Value | List of FaceResult |
import com.ttv.face.FaceEngine;
...
List<FaceResult> detectResult = FaceEngine.getInstance(this).detectFace(bitmap);
List<FaceResult> detectFace(byte[] nv21, int width, int height)
Name | Description |
---|---|
Function | Get Detection Result from Bitmap image |
Parameters | NV21 YUV ByteArray with it's width and height |
Return Value | List of FaceResult |
import com.ttv.face.FaceEngine;
...
List<FaceResult> detectResult = FaceEngine.getInstance(this).detectFace(nv21, width, height);
int extractFeature(Bitmap bitmap, boolean isRegister, List<FaceResult> faceResults)
Name | Description |
---|---|
Function | Extract Face Feature from Detected Face |
Parameters | Android Bitmap format Image, extract feature for register or not |
Return Value | 0: Succeed, -1: Failed If successful, the feature should be get the feature in FaceResult |
import com.ttv.face.FaceEngine;
...
List<FaceResult> detectResult = FaceEngine.getInstance(this).extractFeature(bitmap, isRegister, faceResults);
int extractFeature(byte[] nv21, int width, int height, boolean isRegister, List faceResults)
Name | Description |
---|---|
Function | Extract Face Feature from Detected Face |
Parameters | NV21 YUV ByteArray with Width and Height, extract feature for register or not |
Return Value | 0: Succeed, -1: Failed If successful, the feature should be get the feature in FaceResult |
import com.ttv.face.FaceEngine;
...
List<FaceResult> detectResult = FaceEngine.getInstance(this).extractFeature(bitmap, isRegister, faceResults);
float compareFace(byte[] feat1, byte[] feat2)
Name | Description |
---|---|
Function | Check two faces are same or not from Feat Array |
Parameters | Face Features to compare |
Return Value | Score of Face Comparison (Threshold for same faces 0.82) |
import com.ttv.face.FaceEngine;
...
float score = FaceEngine.getInstance(this).compareFace(feat1, feat2);
int livenessProcess(Bitmap bitmap, List<FaceResult> faceResults)
Name | Description |
---|---|
Function | Check Liveness from Detected Face |
Parameters | Android Bitmap format Image |
Return Value | 0: Succeed, -1: Failed If successful, set Liveness Value to FaceResults |
import com.ttv.face.FaceEngine;
...
float score = FaceEngine.getInstance(this).livenessProcess(bitmap, faceResults);
int livenessProcess(byte[] nv21, int width, int height, List<FaceResult> faceResults)
Name | Description |
---|---|
Function | Check Liveness from Detected Face |
Parameters | NV21 YUV ByteArray with Width and Height |
Return Value | 0: Succeed, -1: Failed If successful, Set Liveness Value to FaceResults |
import com.ttv.face.FaceEngine;
...
float score = FaceEngine.getInstance(this).livenessProcess(nv21, width, height, faceResults);
int faceAttrProcess(Bitmap bitmap, List<FaceResult> faceResults)
Name | Description |
---|---|
Function | Detect Attributes(Gender, Age, Yaw, Roll, Pitch, Mask) from Face |
Parameters | Android Bitmap format Image |
Return Value | 0: Succeed, -1: Failed If successful, Set Attributes Value to FaceResults |
import com.ttv.face.FaceEngine;
...
float score = FaceEngine.getInstance(this).faceAttrProcess(bitmap, faceResults);
Function: Detect Attributes(Liveness, Gender, Age, Yaw, Roll, Pitch, Mask) from Face
Name | Description |
---|---|
Function | Detect Attributes(Gender, Age, Yaw, Roll, Pitch, Mask) from Face |
Parameters | NV21 YUV ByteArray with Width and Height |
Return Value | 0: Succeed, -1: Failed If successful, Set Attributes Value to FaceResults |
import com.ttv.face.FaceEngine;
...
float score = FaceEngine.getInstance(this).faceAttrProcess(nv21, width, height, faceResults);
int faceAllProcess(Bitmap bitmap, boolean isRegister, List<FaceResult> faceResults)
Name | Description |
---|---|
Function | Extract Face Feature, Liveness, Get Attributes from Detected Face |
Parameters | Android Bitmap format Image |
Return Value | 0: Succeed, -1: Failed If successful, Set All Attributes Value to FaceResults |
import com.ttv.face.FaceEngine;
...
float score = FaceEngine.getInstance(this).faceAllProcess(bitmap, faceResults);
int faceAllProcess(Bitmap bitmap, boolean isRegister, List<FaceResult> faceResults)
Name | Description |
---|---|
Function | Extract Face Feature, Liveness, Get Attributes from Detected Face |
Parameters | NV21 YUV ByteArray with Width and Height, extract feature for register or not |
Return Value | 0: Succeed, -1: Failed If successful, Set All Attributes Value to FaceResults |
import com.ttv.face.FaceEngine;
...
float score = FaceEngine.getInstance(this).faceAllProcess(nv21, width, height, faceResults);