Skip to content

Commit

Permalink
Merge pull request #6 from Yoonit-Labs/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Goulartvic authored Mar 2, 2021
2 parents c048818 + 7b7f688 commit 73ed196
Show file tree
Hide file tree
Showing 15 changed files with 817 additions and 17 deletions.
110 changes: 109 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,109 @@
# android-yoonit-facefy
<img src="https://raw.githubusercontent.com/Yoonit-Labs/android-yoonit-camera/development/logo_cyberlabs.png" width="300">

# android-yoonit-facefy

A Android library to provide:
- [Standart Google ML Kit](https://developers.google.com/ml-kit)
- Face detection
- Face contours
- Face expressions
- Face movement

## Install

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

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

Add the dependency

```groovy
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.

```kotlin
import ai.cyberlabs.yoonit.facefy.Facefy

...

fun example(inputImage: InputImage) {
Facefy()
.detect(
inputImage,
{ faceDetected ->
val boudingBox: 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
},
{ message ->
val mesage: String = message
}
)
}
```

## API

### Methods

| Function | Parameters | Return Type | Description |
| - | - | - | - |
| detect | `image: InputImage, onFaceDetected: (FaceDetected) -> Unit, onMessage: (String) -> Unit` | void | Detect a face from image and return the result in the [`FaceDetected`](#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 smilling probability. |
| headEulerAngleX | Float | The angle that points the rotation of the face about the horizontal axis of the image |
| headEulerAngleY | Float | The angle that points the "left-right" head direction. See [HeadEulerAngleY](#headeulerangley) |
| headEulerAngleZ | Float | The angle that points the rotation of the face about the axis pointing out of the image |
| contours | Mutablelist<PointF> | List of Points that represents the shape of the recognized face. |
| boundingBox | Rect | The face bounding box. |

#### HeadEulerAngleY

Landmarks are points of interest within a face regarding the Euler Angle Y

| Euler Angle Y | Detectable landmarks
| - | -
| < -36 degrees | left eye, left mouth, left ear, nose base, left cheek
| -36 degrees to -12 degrees | left mouth, nose base, bottom mouth, right eye, left eye, left cheek, left ear tip
| -12 degrees to 12 degrees | right eye, left eye, nose base, left cheek, right cheek, left mouth, right mouth, bottom mouth
| 12 degrees to 36 degrees | right mouth, nose base, bottom mouth, left eye, right eye, right cheek, right ear tip
| > 36 degrees | right eye, right mouth, right ear, nose base, right cheek

#### Contours

Contours is a list of Points that represents the shape of the recognized face

## To contribute and make it better

Clone the repo, change what you want and send PR.

Contributions are always welcome!

---

Code with ❤ by the [**Cyberlabs AI**](https://cyberlabs.ai/) Front-End Team
23 changes: 20 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
}

android {
Expand All @@ -9,7 +11,7 @@ android {

defaultConfig {
applicationId "ai.cyberlabs.yoonit.facefydemo"
minSdkVersion 24
minSdkVersion 22
targetSdkVersion 30
versionCode 1
versionName "1.0"
Expand All @@ -23,6 +25,11 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

buildFeatures {
dataBinding true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand All @@ -33,9 +40,19 @@ android {
}

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.2.0'
implementation project(path: ":yoonit-facefy")

implementation "androidx.core:core-ktx:$ktx_version"

kapt 'com.android.databinding:compiler:3.1.4'

implementation "com.google.mlkit:face-detection:$mlkit_version"

implementation 'com.github.Yoonit-Labs:android-yoonit-camera:2.6.0'

implementation "androidx.constraintlayout:constraintlayout:2.0.4"

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
testImplementation 'junit:junit:4.+'
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Facefydemo" />
android:theme="@style/Theme.Facefydemo"
android:screenOrientation="fullSensor">

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>
Loading

0 comments on commit 73ed196

Please sign in to comment.