Face Services
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(e.g.CENTER,LEFT,RIGHT,TOP,BOTTOM,TOP_LEFT,TOP_RIGHT,BOTTOM_LEFT,BOTTOM_RIGHT,SLIGHTLY_LEFT,SLIGHTLY_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.
InstaVision.faceServices.uploadFaceAngles(
folder = "folder",
faceAngles = faceAngles,
authToken = "authToken",
uploadUrl = "uploadUrl",
uploadCount = { count ->
// The number of images uploaded so far
},
onSuccess = { message ->
// The success message
},
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).
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
}
)