Note: This image doesn’t demonstrate all recognition features.

We can see a collection of different data here, so let’s break it down:

FirebaseVisionFace.boundingBox

With our face instance we get a bounding box which represents the bounds of the detected face. This is in the form of a Rect instance, so can be used to easily draw the box onto the canvas.

val bounds = face.boundingBox

We can also retrieve the rotations of the face based on whether the face is tilted at all — if so, we could use these to alter the way in which we handle the other properties given to us by the FirebaseVisionFace instance.

val rotationY = face.headEulerAngleY

val rotationZ = face.headEulerAngleZ

FirebaseVisionFace.leftEyeOpenProbability

We can retrieve the probability the the face has its left eye open using the leftEyeOpenProbability property on our face instance. We must first check that the property was not un-computed using the FirebaseVisionFace.UNCOMPUTED_PROBABILITY field, then we can retrieve the probability value:

if (face.leftEyeOpenProbability !=

FirebaseVisionFace.UNCOMPUTED_PROBABILITY) {

val leftEyeOpenProb = face.leftEyeOpenProbability

}

The value returned here will be a probability between 0.0 and 1.0.

FirebaseVisionFace.rightEyeOpenProbability

We can retrieve the probability the the face has its right eye open using the rightEyeOpenProbability property on our face instance. We must first check that the property was not un-computed using the FirebaseVisionFace.UNCOMPUTED_PROBABILITY field, then we can retrieve the probability value:

if (face.rightEyeOpenProbability !=

FirebaseVisionFace.UNCOMPUTED_PROBABILITY) {

val rightEyeOpenProb = face.rightEyeOpenProbability

}

The value returned here will be a probability between 0.0 and 1.0.

FirebaseVisionFace.smilingProbability

We can retrieve the probability the the face is smiling using the smilingProbability property on our face instance. We must first check that the property was not un-computed using the FirebaseVisionFace.UNCOMPUTED_PROBABILITY field, then we can retrieve the probability value:

if (face.smilingProbability !=

FirebaseVisionFace.UNCOMPUTED_PROBABILITY) {

val smileProb = face.smilingProbability

}

The value returned here will be a probability between 0.0 and 1.0.

FirebaseVisionFaceLandmark.LEFT_MOUTH

We can retrieve the position for the left-hand side of the mouth by retrieving the FirebaseVisionFaceLandmark.LEFT_MOUTH landmark from the vision face instance.

val leftMouth = face.getLandmark(

FirebaseVisionFaceLandmark.LEFT_MOUTH) leftMouth?.let {

val leftMouthPos = leftMouth.position

}

FirebaseVisionFaceLandmark.RIGHT_MOUTH

We can retrieve the position for the right-hand side of the mouth by retrieving the FirebaseVisionFaceLandmark.RIGHT_MOUTH landmark from the vision face instance.

val rightMouth = face.getLandmark(

FirebaseVisionFaceLandmark.RIGHT_MOUTH) rightMouth?.let {

val rightMouthPos = rightMouth.position

}

FirebaseVisionFaceLandmark.BOTTOM_MOUTH

We can also retrieve the position for the bottom of the mouth by retrieving the FirebaseVisionFaceLandmark.BOTTOM_MOUTH landmark from the vision face instance.

val bottomMouth = face.getLandmark(

FirebaseVisionFaceLandmark.BOTTOM_MOUTH) bottomMouth?.let {

val bottomMouthPos = bottomMouth.position

}

FirebaseVisionFaceLandmark.LEFT_EAR

We can retrieve the position for the left ear by retrieving the FirebaseVisionFaceLandmark.LEFT_EAR landmark from the vision face instance.

val leftEar = face.getLandmark(

FirebaseVisionFaceLandmark.LEFT_EAR) leftEar?.let {

val leftEarPos = leftEar.position

}

FirebaseVisionFaceLandmark.RIGHT_EAR

We can retrieve the position for the right ear by retrieving the FirebaseVisionFaceLandmark.RIGHT_EAR landmark from the vision face instance.

val rightEar = face.getLandmark(

FirebaseVisionFaceLandmark.RIGHT_EAR) rightEar?.let {

val rightEarPos = rightEar.position

}

FirebaseVisionFaceLandmark.LEFT_CHEEK

We can retrieve the position for the left cheek by retrieving the FirebaseVisionFaceLandmark.LEFT_CHEEK landmark from the vision face instance.

val leftCheek = face.getLandmark(

FirebaseVisionFaceLandmark.LEFT_CHEEK) leftCheek?.let {

val leftCheekPos = leftCheek.position

}

FirebaseVisionFaceLandmark.RIGHT_CHEEK

We can retrieve the position for the right cheek by retrieving the FirebaseVisionFaceLandmark.RIGHT_CHEEK landmark from the vision face instance.

val rightCheek = face.getLandmark(

FirebaseVisionFaceLandmark.RIGHT_CHEEK) rightCheek?.let {

val rightCheekPos = rightCheek.position

}

FirebaseVisionFaceLandmark.NOSE_BASE

We can also retrieve the position for the base of the nose by retrieving the FirebaseVisionFaceLandmark.NOSE_BASE landmark from the vision face instance.