-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 05b8c59
Showing
1 changed file
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# FaceLivenessDetection-Android | ||
|
||
## Introduction | ||
This demo showcases a 3D passive liveness detection technique for detecting spoofed faces. | ||
|
||
In real-time, a single image captured from the Android camera computes a liveness score. | ||
|
||
## Try the APK | ||
|
||
You can test the demo APK by following the link below: | ||
|
||
https://drive.google.com/file/d/1U7-wHmRYb8VV32kOb6JdG_sdZA_3bSLe/view?usp=sharing | ||
|
||
## SDK License | ||
|
||
This project uses kby-ai's liveness detection SDK. The SDK requires a license per application ID. | ||
|
||
- The code below shows how to use the license: https://github.com/kby-ai/FaceLivenessDetection-Android/blob/e5ca47f69de1159db81ca68908e039c45c022f8b/app/src/main/java/com/kbyai/facelivedemo/CameraActivity.java#L69-L77 | ||
|
||
- To request a license, please contact us: | ||
``` | ||
Email: kbyai200914@gmail.com | ||
Skype: live:.cid.66e2522354b1049b | ||
Telegram: kbyai | ||
WahtsApp: +19092802609 | ||
``` | ||
|
||
## About SDK | ||
|
||
### Set up | ||
1. Copy the SDK (libfacesdk folder) to the root folder of your project. | ||
|
||
2. Add SDK to the project in settings.gradle | ||
``` | ||
include ':libfacesdk' | ||
``` | ||
|
||
3. Add dependency to your build.gradle | ||
``` | ||
implementation project(path: ':libfacesdk') | ||
``` | ||
|
||
### Initializing an SDK | ||
|
||
- Step One | ||
|
||
To begin, you need to activate the SDK using the license that you have received. | ||
``` | ||
FaceSDK.setActivation("...") | ||
``` | ||
|
||
If activation is successful, the return value will be SDK_SUCCESS. Otherwise, an error value will be returned. | ||
|
||
- Step Two | ||
|
||
After activation, call the SDK's initialization function. | ||
``` | ||
FaceSDK.init(getAssets()); | ||
``` | ||
If initialization is successful, the return value will be SDK_SUCCESS. Otherwise, an error value will be returned. | ||
|
||
### Face Detection and Liveness Detection | ||
|
||
The FaceSDK offers a single function for detecting face and liveness detection, which can be used as follows: | ||
``` | ||
FaceSDK.faceDetection(bitmap) | ||
``` | ||
|
||
This function takes a single parameter, which is a bitmap object. The return value of the function is a list of FaceBox objects. Each FaceBox object contains the detected face rectangle, liveness score, and facial angles such as yaw, roll, and pitch. | ||
|
||
### Yuv to Bitmap | ||
The SDK provides a function called yuv2Bitmap, which converts a yuv frame to a bitmap. Since camera frames are typically in yuv format, this function is necessary to convert them to bitmaps. The usage of this function is as follows: | ||
``` | ||
Bitmap bitmap = FaceSDK.yuv2Bitmap(nv21, image.getWidth(), image.getHeight(), 7); | ||
``` | ||
The first parameter is an nv21 byte array containing the yuv data. | ||
|
||
The second parameter is the width of the yuv frame, and the third parameter is its height. | ||
|
||
The fourth parameter is the conversion mode, which is determined by the camera orientation. | ||
|
||
To determine the appropriate conversion mode, the following method can be used: | ||
``` | ||
1 2 3 4 5 6 7 8 | ||
888888 888888 88 88 8888888888 88 88 8888888888 | ||
88 88 88 88 88 88 88 88 88 88 88 88 | ||
8888 8888 8888 8888 88 8888888888 8888888888 88 | ||
88 88 88 88 | ||
88 88 888888 888888 | ||
``` |