Skip to content

Commit fcee16c

Browse files
author
MingDongdev
committed
Initial files
0 parents  commit fcee16c

File tree

76 files changed

+4482
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+4482
-0
lines changed

.gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties
16+
/.idea/

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# FacePlugin-FaceSDK-Android

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'org.jetbrains.kotlin.android'
4+
}
5+
6+
android {
7+
namespace 'com.faceplugin.faceattribute'
8+
compileSdk 33
9+
10+
defaultConfig {
11+
applicationId "com.faceplugin.faceattribute"
12+
minSdk 24
13+
targetSdk 33
14+
versionCode 2
15+
versionName "1.1"
16+
17+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18+
19+
ndk {
20+
abiFilters 'arm64-v8a', 'armeabi-v7a'
21+
}
22+
}
23+
24+
buildTypes {
25+
release {
26+
minifyEnabled false
27+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
28+
}
29+
}
30+
compileOptions {
31+
sourceCompatibility JavaVersion.VERSION_1_8
32+
targetCompatibility JavaVersion.VERSION_1_8
33+
}
34+
kotlinOptions {
35+
jvmTarget = '1.8'
36+
}
37+
}
38+
39+
dependencies {
40+
41+
42+
implementation 'androidx.appcompat:appcompat:1.6.1'
43+
implementation 'com.google.android.material:material:1.8.0'
44+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
45+
implementation 'androidx.preference:preference:1.2.0'
46+
implementation 'androidx.preference:preference-ktx:1.2.0'
47+
48+
implementation "androidx.camera:camera-core:1.0.0-beta12"
49+
implementation "androidx.camera:camera-camera2:1.0.0-beta12"
50+
implementation "androidx.camera:camera-lifecycle:1.0.0-beta12"
51+
implementation 'androidx.camera:camera-view:1.0.0-alpha19'
52+
53+
implementation project(path: ':libfacesdk')
54+
55+
implementation 'io.fotoapparat:fotoapparat:2.7.0'
56+
57+
testImplementation 'junit:junit:4.13.2'
58+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
59+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
60+
implementation 'com.royrodriguez:transitionbutton:0.2.0'
61+
}

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.faceplugin.faceattribute
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.faceplugin.faceattribute", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-permission android:name="android.permission.CAMERA" />
6+
7+
<uses-feature android:name="android.hardware.camera" />
8+
9+
<application
10+
android:allowBackup="true"
11+
android:dataExtractionRules="@xml/data_extraction_rules"
12+
android:fullBackupContent="@xml/backup_rules"
13+
android:icon="@mipmap/ic_launcher"
14+
android:label="@string/app_name"
15+
android:supportsRtl="true"
16+
android:theme="@style/Theme.FaceAttribute"
17+
tools:targetApi="31">
18+
<activity
19+
android:name=".AttributeActivity"
20+
android:exported="false" />
21+
<activity
22+
android:name=".ResultActivity"
23+
android:exported="false"
24+
android:screenOrientation="portrait" />
25+
<activity
26+
android:name=".SettingsActivity"
27+
android:exported="false"
28+
android:label="@string/title_activity_settings"
29+
android:screenOrientation="portrait" />
30+
<activity
31+
android:name=".AboutActivity"
32+
android:exported="false"
33+
android:screenOrientation="portrait" />
34+
<activity
35+
android:name=".CameraActivity"
36+
android:exported="false"
37+
android:screenOrientation="portrait" />
38+
<activity
39+
android:name=".CameraActivityKt"
40+
android:exported="false"
41+
android:screenOrientation="portrait" />
42+
<activity
43+
android:name=".CaptureActivity"
44+
android:exported="false"
45+
android:screenOrientation="portrait" />
46+
<activity
47+
android:name=".MainActivity"
48+
android:exported="true"
49+
android:screenOrientation="portrait">
50+
<intent-filter>
51+
<action android:name="android.intent.action.MAIN" />
52+
53+
<category android:name="android.intent.category.LAUNCHER" />
54+
</intent-filter>
55+
</activity>
56+
</application>
57+
58+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.faceplugin.faceattribute
2+
3+
import android.content.Intent
4+
import android.content.pm.ResolveInfo
5+
import android.net.Uri
6+
import android.os.Bundle
7+
import android.widget.TextView
8+
import androidx.appcompat.app.AppCompatActivity
9+
10+
11+
class AboutActivity : AppCompatActivity() {
12+
override fun onCreate(savedInstanceState: Bundle?) {
13+
super.onCreate(savedInstanceState)
14+
setContentView(R.layout.activity_about)
15+
16+
findViewById<TextView>(R.id.txtMail).setOnClickListener {
17+
val intent = Intent(Intent.ACTION_SEND)
18+
intent.type = "plain/text"
19+
intent.putExtra(Intent.EXTRA_EMAIL, arrayOf("[email protected]"))
20+
intent.putExtra(Intent.EXTRA_SUBJECT, "License Request")
21+
intent.putExtra(Intent.EXTRA_TEXT, "")
22+
startActivity(Intent.createChooser(intent, ""))
23+
}
24+
25+
findViewById<TextView>(R.id.txtWhatsapp).setOnClickListener {
26+
val general = Intent(Intent.ACTION_VIEW, Uri.parse("https://wa.me/+14422295661"))
27+
val generalResolvers: HashSet<String> = HashSet()
28+
val generalResolveInfo: List<ResolveInfo> = packageManager.queryIntentActivities(general, 0)
29+
for (info in generalResolveInfo) {
30+
if (info.activityInfo.packageName != null) {
31+
generalResolvers.add(info.activityInfo.packageName)
32+
}
33+
}
34+
35+
val telegram = Intent(Intent.ACTION_VIEW, Uri.parse("https://wa.me/+14422295661"))
36+
var goodResolver = 0
37+
38+
val resInfo: List<ResolveInfo> = packageManager.queryIntentActivities(telegram, 0)
39+
if (!resInfo.isEmpty()) {
40+
for (info in resInfo) {
41+
if (info.activityInfo.packageName != null && !generalResolvers.contains(info.activityInfo.packageName)) {
42+
goodResolver++
43+
telegram.setPackage(info.activityInfo.packageName)
44+
}
45+
}
46+
}
47+
48+
if (goodResolver != 1) {
49+
telegram.setPackage(null)
50+
}
51+
if (telegram.resolveActivity(packageManager) != null) {
52+
startActivity(telegram)
53+
}
54+
}
55+
56+
findViewById<TextView>(R.id.txtTelegram).setOnClickListener {
57+
val general = Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/andywu0202"))
58+
val generalResolvers: HashSet<String> = HashSet()
59+
val generalResolveInfo: List<ResolveInfo> = packageManager.queryIntentActivities(general, 0)
60+
for (info in generalResolveInfo) {
61+
if (info.activityInfo.packageName != null) {
62+
generalResolvers.add(info.activityInfo.packageName)
63+
}
64+
}
65+
66+
val telegram = Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/andywu0202"))
67+
var goodResolver = 0
68+
69+
val resInfo: List<ResolveInfo> = packageManager.queryIntentActivities(telegram, 0)
70+
if (!resInfo.isEmpty()) {
71+
for (info in resInfo) {
72+
if (info.activityInfo.packageName != null && !generalResolvers.contains(info.activityInfo.packageName)) {
73+
goodResolver++
74+
telegram.setPackage(info.activityInfo.packageName)
75+
}
76+
}
77+
}
78+
79+
if (goodResolver != 1) {
80+
telegram.setPackage(null)
81+
}
82+
if (telegram.resolveActivity(packageManager) != null) {
83+
startActivity(telegram)
84+
}
85+
}
86+
}
87+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.faceplugin.faceattribute
2+
3+
import android.graphics.Bitmap
4+
import android.os.Bundle
5+
import android.widget.ImageView
6+
import android.widget.TextView
7+
import androidx.appcompat.app.AppCompatActivity
8+
9+
class AttributeActivity : AppCompatActivity() {
10+
override fun onCreate(savedInstanceState: Bundle?) {
11+
super.onCreate(savedInstanceState)
12+
setContentView(R.layout.activity_attribute)
13+
14+
val faceImage = intent.getParcelableExtra("face_image") as? Bitmap
15+
val livenessScore = intent.getFloatExtra("liveness", 0f)
16+
val yaw = intent.getFloatExtra("yaw", 0f)
17+
val roll = intent.getFloatExtra("roll", 0f)
18+
val pitch = intent.getFloatExtra("pitch", 0f)
19+
val face_quality = intent.getFloatExtra("face_quality", 0f)
20+
val face_luminance = intent.getFloatExtra("face_luminance", 0f)
21+
val left_eye_closed = intent.getFloatExtra("left_eye_closed", 0f)
22+
val right_eye_closed = intent.getFloatExtra("right_eye_closed", 0f)
23+
val face_occlusion = intent.getFloatExtra("face_occlusion", 0f)
24+
val mouth_opened = intent.getFloatExtra("mouth_opened", 0f)
25+
val age = intent.getIntExtra("age", 0)
26+
val gender = intent.getIntExtra("gender", 0)
27+
28+
findViewById<ImageView>(R.id.imageFace).setImageBitmap(faceImage)
29+
30+
if (livenessScore > SettingsActivity.getLivenessThreshold(this)) {
31+
val msg = String.format("Liveness: Real, score = %.03f", livenessScore)
32+
findViewById<TextView>(R.id.txtLiveness).text = msg
33+
} else {
34+
val msg = String.format("Liveness: Spoof, score = %.03f", livenessScore)
35+
findViewById<TextView>(R.id.txtLiveness).text = msg
36+
}
37+
38+
if (face_quality < 0.5f) {
39+
val msg = String.format("Quality: Low, score = %.03f", face_quality)
40+
findViewById<TextView>(R.id.txtQuality).text = msg
41+
} else if(face_quality < 0.75f){
42+
val msg = String.format("Quality: Medium, score = %.03f", face_quality)
43+
findViewById<TextView>(R.id.txtQuality).text = msg
44+
} else {
45+
val msg = String.format("Quality: High, score = %.03f", face_quality)
46+
findViewById<TextView>(R.id.txtQuality).text = msg
47+
}
48+
49+
var msg = String.format("Luminance: %.03f", face_luminance)
50+
findViewById<TextView>(R.id.txtLuminance).text = msg
51+
52+
msg = String.format("Angles: yaw = %.03f, roll = %.03f, pitch = %.03f", yaw, roll, pitch)
53+
findViewById<TextView>(R.id.txtAngles).text = msg
54+
55+
if (face_occlusion > SettingsActivity.getOcclusionThreshold(this)) {
56+
msg = String.format("Face occluded: score = %.03f", face_occlusion)
57+
findViewById<TextView>(R.id.txtOcclusion).text = msg
58+
} else {
59+
msg = String.format("Face not occluded: score = %.03f", face_occlusion)
60+
findViewById<TextView>(R.id.txtOcclusion).text = msg
61+
}
62+
63+
msg = String.format("Left eye closed: %b, %.03f, Right eye closed: %b, %.03f", left_eye_closed > SettingsActivity.getEyecloseThreshold(this),
64+
left_eye_closed, right_eye_closed > SettingsActivity.getEyecloseThreshold(this), right_eye_closed)
65+
findViewById<TextView>(R.id.txtEyeClosed).text = msg
66+
67+
msg = String.format("Mouth opened: %b, %.03f", mouth_opened > SettingsActivity.getMouthopenThreshold(this), mouth_opened)
68+
findViewById<TextView>(R.id.txtMouthOpened).text = msg
69+
70+
msg = String.format("Age: %d", age)
71+
findViewById<TextView>(R.id.txtAge).text = msg
72+
73+
if(gender == 0) {
74+
msg = String.format("Gender: Male")
75+
} else {
76+
msg = String.format("Gender: Female")
77+
}
78+
findViewById<TextView>(R.id.txtGender).text = msg
79+
}
80+
}

0 commit comments

Comments
 (0)