Face matching

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

Swift
Objective-C
Swift
var matchRequestImages = [Image]()
let firstImage = Image(image: UIImage(named: "firstImage")!)
firstImage.imageType = .printed
matchRequestImages.append(firstImage)
let secondImage = Image(image: UIImage(named: "secondImage")!)
secondImage.imageType = .printed
matchRequestImages.append(secondImage)
let request = MatchFacesRequest(images: matchRequestImages)
Face.service.matchFaces(request, completion: { (response: MatchFacesResponse?) in
// do smth
})
Objective-C
NSMutableArray *matchRequestImages = [[NSMutableArray alloc] init];
RGLImage *firstImage = [[RGLImage alloc] initWithImage:[UIImage imageNamed:@"firstImage"]];
firstImage.imageType = RGLImageTypePrinted;
[matchRequestImages addObject: firstImage];
RGLImage *secondImage = [[RGLImage alloc] initWithImage:[UIImage imageNamed:@"secondImage"]];
secondImage.imageType = RGLImageTypePrinted;
[matchRequestImages addObject: secondImage];
RGLMatchFacesRequest *request = [[RGLMatchFacesRequest alloc] initWithImages:matchRequestImages];
[RGLFace.service matchFaces:request completion:^(RGLMatchFacesResponse * _Nullable response) {
// do smth
}];

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, e.g.:

Swift
Objective-C
Swift
request.similarityThreshold = 0.75
Objective-C
request.similarityThreshold = @0.75;

There is a possibility to close the capture controller programmatically:

Swift
Objective-C
Swift
Face.service.stopCaptureViewController()
Objective-C
[RGLFace.service stopFaceCaptureViewController];

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

First image

second

Second image

tag

Tag

imageType

Image type

position

Position an image in the array