Documentation
Document for Android SDK 3.2 can be found here https://trueface-libraries-docs.web.app
Releases
Trueface SDK 3.1.0 - performance enhancement. support for GPU, add support for landmark detection, deprecated both blink and spoof, support for better liveness is coming soon.
Trueface SDK 3.0.2 - introduce breaking changes, new database management, inline java docs
Trueface SDK 2.9.1 (C++ SDK 0.8) - supports new spoof, mask detector, glasses detector, faster live frame processor. supports 32-bit (armeabi-v7a - x86) and 64-bit (arm64-v8a - x86_64)
Version 2.8 (SDK 0.3) - supports ARM64-V8A and x86, Minimum Android version for this release is 24.
This Android binding of Trueface SDK is in beta status, subject for further improvement, enhancement and additional features.
License
To obtain a License key, please contact our sales team and provide your applicationId
.
Configuration
To setup the Trueface mobile SDK in Android Studio please import trueface-*.aar as new module (File -> New -> New Module), then add it as dependency via module settings.
Examples
Initialize the SDK, set and check validity of license
SDK sdk = new SDK(getApplicationContext());
sdk.setLicense(“…”);
if (sdk.isLicensed()) {
…
}
Set Image from Bitmap
ErrorCode errorCode = sdk.setImage(bitmap);
Set Image from bytes[] — useful for live image YUV processing
ErroCode erroCode = sdk.setImage(width, height, data);
Detect objects in image
BoundingBox[] boundingBoxs = sdk.detectObjects();
for (BoundingBox boundingBox: boundingBoxs) {
…
}
Detect Spoof Attempt
Spoof spoofDetection = sdk.detectSpoof();
if (spoofDetection.spoofDetection <= 0.6) {
// no spoof attempt detected
}
Test liveness by detecting blinking
BlinkDetection blinkDetection = sdk.detectBlink();
if (blinkDetection.isBlinking) {
…
}
Detect largest face
FaceBoxAndLandmarks faceBoxAndLandmarks = sdk.detectLargestFace();
Detect Glasses
GlassesLabel detectGlasses(FaceBoxAndLandmarks faceBoxAndLandmarks);
Detect Mask
MaskResult detectMask(FaceBoxAndLandmarks faceBoxAndLandmarks);
Face recognition
ConfigurationOptions options = new ConfigurationOptions();
options.smallestFaceWidth = 40;
SDK sdk = new SDK(options);
sdk.setLicense(“…”);
Bitmap bitmap = getBitmapFromAsset("mr_bean.jpg");
ErrorCode errorCode = sdk.setImage(bitmap);
float[] vector1 = sdk.getLargestFaceFeatureVector();
bitmap = getBitmapFromAsset(appContext, "mr_bean_2.jpg");
errorCode = sdk.setImage(bitmap);
float[] vector2 = sdk.getLargestFaceFeatureVector();
Similarity similarity = sdk.getSimilarity(vector1, vector2);
If (similarity.similarityMeasure > 0.6) {
…
}
Pose estimation
FaceBoxAndLandmarks faceBoxAndLandmarks = sdk.detectLargestFace();
EstimateHeadOrientation estimateHeadOrientation = sdk.estimateHeadOrientation(faceBoxAndLandmarks);
API
// parent SDK version
String getVersion()
// mobile SDK version
String getMobileVersion()
// Validates the given license token. Need to call this method before being able to use the SDK.
boolean setLicense(String token)
boolean isLicensed()
// Set the image that is processed by the other methods.
ErrorCode setImage(Bitmap bitmap, ColorCode color)
// Detect people and objects in the image.
BoundingBox[] detectObjects()
// Estimate score for eyes blink
BlinkDetection detectBlink()
// Estimate score for Spoof attempt
Spoof detectSpoof(float threshold)
// Detect the largest face in the image.
FaceBoxAndLandmarks detectLargestFace()
// Detect the largest face in the image and return its feature vector.
float[] getLargestFaceFeatureVector()
// Compute the similarity between two feature vectors, or how similar two faces are.
Similarity getSimilarity(float[] featureVector1, float[] featureVector2)
// Estimate the head pose.
EstimateHeadOrientation estimateHeadOrientation(FaceBoxAndLandmarks faceBoxAndLandmarks)