Face Recognition
Face services are a set of APIs that allow you to manage the faces enrolled in a space, used for face recognition.
Pre-requisite: The user has to be signed in to perform the following operations.
Get the faces
To get the list of faces enrolled in a space, the following method can be used:
spaceId(required): The space ID to fetch the faces for.
InstaVision.faceServices.getFaces(
spaceId = "spaceId",
onSuccess = { authorizationToken, faces ->
// The authorization token and the list of face objects
},
onError = { error ->
// The error object contains the error code and message
}
)
Create a face
To create a new face enrollment, the following method can be used:
spaceId(required): The space ID to create the face in.name(required): The name of the face.
InstaVision.faceServices.createFace(
spaceId = "spaceId",
name = "name",
onSuccess = { createFaceResponse ->
// The created face response, including the authorization token, face ID, upload URL and folder
},
onError = { error ->
// The error object contains the error code and message
}
)
Upload face angles
To upload the captured face angle images for enrollment, the following method can be used:
folder(required): The folder path to upload the images to.faceAngles(required): A map ofFaceAngles(CENTER,LEFT,RIGHT,TOP_LEFT,TOP_RIGHT,BOTTOM_LEFT,BOTTOM_RIGHT) to the list of captured bitmaps for that angle.authToken(required): The authorization token returned bycreateFace.uploadUrl(required): The upload URL returned bycreateFace.uploadCount(required): A callback invoked with the running count of images uploaded.onSuccess(required): Receives the thumbnail path and the name of the uploaded zip file.
InstaVision.faceServices.uploadFaceAngles(
folder = "folder",
faceAngles = faceAngles,
authToken = "authToken",
uploadUrl = "uploadUrl",
uploadCount = { count ->
// The number of images uploaded so far
},
onSuccess = { thumbnailPath, zipFileName ->
// The thumbnail path and the name of the uploaded zip file
},
onError = { error ->
// The error object contains the error code and message
}
)
Update a face
To update the details of an enrolled face, the following method can be used:
spaceId(required): The space ID the face belongs to.request(required): TheUpdateFaceRequestobject containing theidof the face and the fields to update (name,status,thumbnail,zipFile).
Set zipFile to the zip file name returned by uploadFaceAngles so the face is matched against the images that were just uploaded.
InstaVision.faceServices.updateFace(
spaceId = "spaceId",
request = UpdateFaceRequest(
id = "faceId",
name = "name",
),
onSuccess = { face ->
// The updated face object
},
onError = { error ->
// The error object contains the error code and message
}
)
Delete a face
To delete an enrolled face, the following method can be used:
spaceId(required): The space ID the face belongs to.faceId(required): The ID of the face to delete.
InstaVision.faceServices.deleteFace(
spaceId = "spaceId",
faceId = "faceId",
onSuccess = {
// The face was deleted successfully
},
onError = { error ->
// The error object contains the error code and message
}
)