Skip to content

The face detection's module for Android with a lot of awesome features

License

Notifications You must be signed in to change notification settings

Yoonit-Labs/android-yoonit-facefy

Repository files navigation

Android Yoonit Facefy

Google MLKit integration

PyTorch integration

◻ Computer vision pipeline

◻ Face detection

◻ Face contours

◻ Face expressions

◻ Face movement

Sponsors

Platinum

Table of Contents

Installation

Add the JitPack repository to your root build.gradle at the end of repositories

allprojects {
	repositories {  
	... 
	maven { url 'https://jitpack.io' }
	} 
}  

Add the dependency

dependencies {
	implementation 'com.github.Yoonit-Labs:android-yoonit-facefy:master-SNAPSHOT'
}

Usage

This is a basic usage to the FacefyYoonit. Feel free to use the demo.

import ai.cyberlabs.yoonit.facefy.Facefy

...

    fun example(inputBitmap: Bitmap) {
        Facefy()
            .detect(
                inputBitmap,
                { faceDetected ->
                    val boundingBox: Rect = faceDetected.boundingBox
                    val contours: MutableList<PointF> = faceDetected.contours
                    val headEulerAngleX: Float = faceDetected.headEulerAngleX
                    val headEulerAngleY: Float = faceDetected.headEulerAngleY
                    val headEulerAngleZ: Float = faceDetected.headEulerAngleZ
                    val leftEyeOpenProbability: Float? = faceDetected.leftEyeOpenProbability
                    val rightEyeOpenProbability: Float? = faceDetected.rightEyeOpenProbability
                    val smilingProbability: Float? = faceDetected.smilingProbability
                },
                { errorMessage ->
                    val mesage: String = errorMessage
                },
                {
                    // Process completed.
                }       
            )
    }

API

Methods

Function Parameters Return Type Description
detect inputBitmap: Bitmap, onSuccess: (FaceDetected) -> Unit, onError: (String) -> Unit void Detect a face from bitmap and return the result in the FaceDetected as a closure.

FaceDetected

Attribute Type Description
leftEyeOpenProbability Float? The left eye open probability.
rightEyeOpenProbability Float? The right eye open probability.
smilingProbability Float? The smiling probability.
headEulerAngleX Float The angle that points the rotation of the face about the horizontal axis of the image. HeadMovements
headEulerAngleY Float The angle that points the "left-right" head direction. See HeadMovements
headEulerAngleZ Float The angle that points the rotation of the face about the axis pointing out of the image. HeadMovements
contours Mutablelist List of Points that represents the shape of the recognized face.
boundingBox Rect The face bounding box.

Head Movements

Here we explaining the above gif and how reached the "results". Each "movement" (vertical, horizontal and tilt) is a state, based in the angle in degrees that indicate head direction;

Head Direction Attribute v < -36° -36° < v < -12° -12° < v < 12° 12° < v < 36° 36° < v
Vertical headEulerAngleX Super Down Down Frontal Up Super Up
Horizontal headEulerAngleY Super Left Left Frontal Right Super Right
Tilt headEulerAngleZ Super Right Right Frontal Left Super Left

To contribute and make it better

Clone the repo, change what you want and send PR. For commit messages we use Conventional Commits.

Contributions are always welcome!


Code with ❤ by the Yoonit Team