Trueface Android SDK

Getting started with Trueface Android's SDK

version 0.8 - supports armeabi-v7a without NEON, arm64-v8a and x86, android minSdkVersion to 23,
Note: as of version 0.8, we have introduced breaking changes to improved performance of SDK, please make sure to test your code and migrate to Frame helper.

License

To obtain a License key, please contact our sales team and provide your applicationId

Configuration

To setup 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.

To construct a FaceRecognizer object, you need to provide an application instance and a valid license key as follows

FaceRecognizer fr = new FaceRecognizer(getApplication());
fr.setLicense("<your license key>");
if (fr.isLicensed()) {
	Log.d(TAG, "the SDK is licensed");
}

getFaces

this method find faces in given frame, the second parameter limits search to first face found only

// holds reference to bmp, to void passing data overhead
Frame frame = new Frame(getApplication(), bmp);

List<Fbox> faces = fr.getFaces(frame, false);
Log.d(TAG, "number of faces found is " + faces.size());
for (Fbox face: faces) {
	Log.d(TAG, String.format("top/left %f/%f bottom/right %f/%f",
		face.x1, face.y1, face.x2, face.y2));
}

// make sure to release frame after usage
// the frame reference will be deleted on app exit
frame.release();

getFace

this method returns a cropped and aligned face in a given frame and annotated by Fbox object

Bitmap face = fr.getFace(frame, faces.get(0));
ImageView faceView = findViewById(R.id.face);
faceView.setImageBitmap(face);

getFaceFeatures / getFaceFeaturesAsCSV

this method returns face features in a given frame and annotated by Fbox object

float[] features = fr.getFaceFeatures(frame, faces.get(0));
String featuresCSV = fr.getFaceFeaturesAsCSV(frame, faces.get(0));

getSimilarity

this method returns the calculated similarity between two face features, the score is between 0 and 1

float[] features1 = fr.getFaceFeatures(frame, faces.get(0));
float[] features2 = fr.getFaceFeatures(frame, faces.get(1));
double similarity = fr.getSimilarity(features1, features2);

Trueface Android SDK


Getting started with Trueface Android's SDK

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.