Skip to content

Instantly share code, notes, and snippets.

@jirawatee
Created July 1, 2018 18:12
Show Gist options
  • Save jirawatee/4ec75614aab20c7a9648926b15ebd661 to your computer and use it in GitHub Desktop.
Save jirawatee/4ec75614aab20c7a9648926b15ebd661 to your computer and use it in GitHub Desktop.
FaceDectorOnDeviceExtract.java
for (FirebaseVisionFace face : faces) {
Rect bounds = face.getBoundingBox();
float rotY = face.getHeadEulerAngleY(); // Head is rotated to the right rotY degrees
float rotZ = face.getHeadEulerAngleZ(); // Head is tilted sideways rotZ degrees
// If landmark detection was enabled (mouth, ears, eyes, cheeks, and
// nose available):
FirebaseVisionFaceLandmark leftEar = face.getLandmark(FirebaseVisionFaceLandmark.LEFT_EAR);
if (leftEar != null) {
FirebaseVisionPoint leftEarPos = leftEar.getPosition();
}
// If classification was enabled:
if (face.getSmilingProbability() != FirebaseVisionFace.UNCOMPUTED_PROBABILITY) {
float smileProb = face.getSmilingProbability();
}
if (face.getRightEyeOpenProbability() != FirebaseVisionFace.UNCOMPUTED_PROBABILITY) {
float rightEyeOpenProb = face.getRightEyeOpenProbability();
}
// If face tracking was enabled:
if (face.getTrackingId() != FirebaseVisionFace.INVALID_ID) {
int id = face.getTrackingId();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment