Add the following dependency in your build.gradle.kts file:
implementation(platform("com.appliedrec:verid-bom:3000.1.0"))
implementation("com.appliedrec:face-recognition-dlib")The library implements the FaceRecognition interface from the Ver-ID-Common-Types package. This makes it compatible with the Ver-ID SDK.
Use a class that implements the FaceDetection interface from the Ver-ID-Common-Types package. For example:
implementation("com.appliedrec:face-detection-retinaface")To create an instance of Image import the Ver-ID serialization library by adding the following dependency:
implementation("com.appliedrec:verid-serialization")suspend fun detectFacesForRecognition(
context: Context,
uri: Uri,
faceDetection: FaceDetection
): List<FaceTemplateArcFace> {
// 1. Read image from URL
val bitmap = context.contentResolver.openInputStream(uri)
.use(BitmapFactory::decodeStream)
// 2. Convert bitmap to Ver-ID image
val image = Image.fromBitmap(bitmap)
// 3. Detect up to 5 faces
val faces = faceDetection.detectFacesInImage(image, 5)
// 4. Create face recognition instance
val templates = FaceRecognitionArcFace(context).use {
// 5. Extract face templates
it.createFaceRecognitionTemplates(faces, image)
}
// 6. Return face templates
return templates
}