Face matching

The code snippet below demonstrates matching two images with printed faces.

Java
Kotlin
Java
MatchFacesRequest matchRequest = new MatchFacesRequest();
Image firstImage = new Image();
firstImage.setImage(image.image());
firstImage.imageType = eInputFaceType.ift_DocumentPrinted;
matchRequest.images.add(firstImage);
Image secondImage = new Image();
secondImage.setImage(image.image());
secondImage.imageType = eInputFaceType.ift_DocumentPrinted;
matchRequest.images.add(secondImage);
Face.Instance().matchFaces(matchRequest, matchFacesResponse -> {
// handling the response
});
Kotlin
var matchRequest = MatchFacesRequest()
var firstImage = Image()
firstImage.setImage(image.image())
firstImage.imageType = eInputFaceType.ift_DocumentPrinted
matchRequest.images.add(firstImage)
var secondImage = Image()
secondImage.setImage(image.image())
secondImage.imageType = eInputFaceType.ift_DocumentPrinted
matchRequest.images.add(secondImage)
Face.Instance().matchFaces(matchRequest) { matchFacesResponse: MatchFacesResponse? ->
// handling the response
}

Declaring an image type is required for correct comparison. It influences matching results.

similarityThreshold indicates the threshold, i.e. if the similarity of faces is under this value, they will be in the unmatchedFaces, otherwise, in the matchedFaces.

There is a possibility to close the capture activity programmatically:

Java
Kotlin
Java
Face.Instance().stopFaceCaptureActivity(MainActivity.this);
Kotlin
Face.Instance().stopFaceCaptureActivity(this@MainActivity)

Response

MatchFacesResponse
└── error
└── matchedFaces
| └── first
| | └── tag
| | └── imageType
| | └── position
| └── second
| | └── tag
| | └── imageType
| | └── position
| └── similarity
| └── error
└── unmatchedFaces
| └── first
| | └── tag
| | └── imageType
| | └── position
| └── second
| | └── tag
| | └── imageType
| | └── position
| └── similarity
| └── error

Parameter

Description

error

Error

matchedFaces

Matched faces

unmatchedFaces

Unmatched faces

first

Fist image

second

Second image

tag

Tag

imageType

Image type

position

Position an image in the array