Face Identification
This module lets you search for a face from an image in a database of faces. Learn more in the Web Service section.
Function call
The function call is searchPerson(searchRequest, callback)
.
searchRequest
is an object representing the search request, it contains the following properties:
- The
groups
property is optional and specifies the groups where the search should be conducted. If no groups are provided, the search is performed in the default group. - The
imageUpload
property represents the image to be uploaded for the search. - The
threshold
property denotes the similarity threshold. - The
limit
property defines the maximum number of results to be returned. - The
detectAll
property enables the detection of all faces in the image. If set to false, only the most central face is detected. - The
outputImageParams
property allows specifying image settings, such as image size and aspect ratio, for the face images that are returned in the identification response.
callback
is a function invoked once the search operation is completed. Includes search results as a list of SearchPerson
objects.
let imageUpload = PersonDatabase.ImageUpload(imageData: yourImageData)
let searchRequest = PersonDatabase.SearchPersonRequest(imageUpload: imageUpload)
searchRequest.groupIdsForSearch = groupIds
searchRequest.detectAll = true
FaceSDK.service.personDatabase.searchPerson(searchRequest: searchRequest) { response in
// handle response
}
RFSImageUpload *imageUpload = [[RFSImageUpload alloc] initWithImageData:yourImageData];
RFSSearchPersonRequest *searchRequest = [[RFSSearchPersonRequest alloc] initWithImageUpload:imageUpload];
searchRequest.groupIdsForSearch = groupIds;
searchRequest.detectAll = YES;
[RFSFaceSDK.service.personDatabase searchPerson:searchRequest completion:^(RFSSearchPersonResponse * _Nonnull response) {
// handle response
}];
val imageUpload = ImageUpload()
val imageData = <byte array>
imageUpload.imageData = imageData
val searchPersonRequest = SearchPersonRequest()
searchPersonRequest.groupIdsForSearch = <array of String>
searchPersonRequest.imageUpload = imageUpload
searchPersonRequest.detectAll = true
FaceSDK.Instance().personDatabase()
.searchPerson(searchPersonRequest, object : PersonDBCallback<List<SearchPerson?>?> {
override fun onSuccess(response: List<SearchPerson?>?) {
//Handle positive response
}
override fun onFailure(message: String) {
//Handle failed request here
}
})
ImageUpload imageUpload = new ImageUpload();
imageUpload.setImageData(byte[] data);
SearchPersonRequest searchPersonRequest = new SearchPersonRequest();
searchPersonRequest.setGroupIdsForSearch(String[] ids);
searchPersonRequest.setImageUpload(imageUpload);
searchPersonRequest.setDetectAll(true);
FaceSDK.Instance().personDatabase().searchPerson(searchPersonRequest,
new PersonDBCallback<List<SearchPerson>>() {
@Override
public void onSuccess(@Nullable List<SearchPerson> response) {
}
@Override
public void onFailure(@NonNull String message) {
//Handle failed request here
}
});
var imageUpload = new ImageUpload();
imageUpload.imageData = "base64";
var searchPersonRequest = new SearchPersonRequest();
searchPersonRequest.groupIdsForSearch = [];
searchPersonRequest.imageUpload = imageUpload;
searchPersonRequest.detectAll = true;
FaceSDK.searchPerson(searchPersonRequest, (response) => {
}, _ => { });
var request = SearchPersonRequest(
ImageUpload.withImageData(imageData),
groupIdsForSearch: ["id1", "id2", "id3"],
detectAll: true,
);
var (searchPerson, error) = await FaceSDK.instance.personDatabase.searchPerson(request);
var imageUpload = new ImageUpload();
imageUpload.imageData = "base64";
var searchPersonRequest = new SearchPersonRequest();
searchPersonRequest.groupIdsForSearch = [];
searchPersonRequest.imageUpload = imageUpload;
searchPersonRequest.detectAll = true;
FaceSDK.searchPerson(searchPersonRequest, function (response) {
}, function (e) { });
var imageUpload = new ImageUpload();
imageUpload.imageData = "base64";
var searchPersonRequest = new SearchPersonRequest();
searchPersonRequest.groupIdsForSearch = [];
searchPersonRequest.imageUpload = imageUpload;
searchPersonRequest.detectAll = true;
FaceSDK.searchPerson(searchPersonRequest).then((response) => {
});
// Android
public void SearchPerson(byte[] data, String[] ids)
{
ImageUpload imageUpload = new();
imageUpload.SetImageData(data);
SearchPersonRequest searchPersonRequest = new();
searchPersonRequest.SetGroupIdsForSearch(ids);
searchPersonRequest.ImageUpload = imageUpload;
searchPersonRequest.DetectAll = true;
FaceSDK.Instance().PersonDatabase().SearchPerson(searchPersonRequest, this);
}
public void OnSuccess(Java.Lang.Object response)
{
}
public void OnFailure(string message)
{
//Handle failed request here
}
// iOS
RFSImageUpload imageUpload = new(yourImageData);
RFSSearchPersonRequest searchRequest = new(imageUpload)
{
GroupIdsForSearch = groupIds,
DetectAll = true
};
RFSFaceSDK.Service.PersonDatabase.SearchPerson(searchRequest, (RFSSearchPersonResponse response) =>
{
// handle response
});
Endpoints
The in-detail information is available in the Face SDK OpenAPI specification: