Using RECOGNITO FaceSDK, you can implement 1:N face identification function.
1:N Face Template Matching Sample Code
Android-FaceRecognition-FaceLivenessDetection/app/src/main/java/com/bio/facerecognition /CameraActivityKt.kt
...
if(faceBoxes.size > 0) {
val faceBox = faceBoxes[0]
if (faceBox.liveness > SettingsActivity.getLivenessThreshold(context)) {
val templates = FaceSDK.templateExtraction(bitmap, faceBox)
var maxSimiarlity = 0f
var maximiarlityPerson: Person? = null
for (person in DBManager.personList) {
val similarity = FaceSDK.similarityCalculation(templates, person.templates)
if (similarity > maxSimiarlity) {
maxSimiarlity = similarity
maximiarlityPerson = person
}
}
if (maxSimiarlity > SettingsActivity.getMatchThreshold(context)) {
recognized = true
val identifiedPerson = maximiarlityPerson
val identifiedSimilarity = maxSimiarlity
runOnUiThread {
val faceImage = Utils.cropFace(bitmap, faceBox)
val intent = Intent(context, ResultActivity::class.java)
intent.putExtra("identified_face", faceImage)
intent.putExtra("enrolled_face", identifiedPerson!!.face)
intent.putExtra("identified_name", identifiedPerson!!.name)
intent.putExtra("similarity", identifiedSimilarity)
intent.putExtra("liveness", faceBox.liveness)
intent.putExtra("yaw", faceBox.yaw)
intent.putExtra("roll", faceBox.roll)
intent.putExtra("pitch", faceBox.pitch)
startActivity(intent)
}
}
}
}
- Window-Face SDK Video Surveillance Demo