Skip to content

Commit

Permalink
Redesign liveness detection
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfaceplugin committed Feb 29, 2024
1 parent dc0052e commit 69c8580
Show file tree
Hide file tree
Showing 31 changed files with 138 additions and 203 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ plugins {
}

android {
namespace 'com.faceplugin.facerecognition'
namespace 'com.faceplugin.faceliveness'
compileSdk 33

defaultConfig {
applicationId "com.faceplugin.facerecognition"
applicationId "com.faceplugin.faceliveness"
minSdk 24
targetSdk 33
versionCode 2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition
package com.faceplugin.faceliveness

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
android:name=".AttributeActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:name=".SplashActivity"
android:exported="false"
android:screenOrientation="portrait"/>
<activity
Expand Down Expand Up @@ -48,7 +48,7 @@
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".SplashActivity"
android:name=".MainActivity"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition
package com.faceplugin.faceliveness

import android.content.Intent
import android.content.pm.ResolveInfo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition
package com.faceplugin.faceliveness

import android.graphics.Bitmap
import android.os.Bundle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition;
package com.faceplugin.faceliveness;


import static androidx.camera.core.ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition
package com.faceplugin.faceliveness

import android.Manifest
import android.content.Context
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition;
package com.faceplugin.faceliveness;


import static androidx.camera.core.ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition;
package com.faceplugin.faceliveness;

import android.animation.Animator;
import android.animation.ValueAnimator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition;
package com.faceplugin.faceliveness;

import android.content.ContentValues;
import android.content.Context;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.faceplugin.faceliveness;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class DatabaseActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition;
package com.faceplugin.faceliveness;

public enum FACE_CAPTURE_STATE {
NO_FACE, MULTIPLE_FACES, FIT_IN_CIRCLE, MOVE_CLOSER, NO_FRONT, FACE_OCCLUDED, EYE_CLOSED, MOUTH_OPENED, SPOOFED_FACE, CAPTURE_OK
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition;
package com.faceplugin.faceliveness;

import android.content.Context;
import android.graphics.Canvas;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition
package com.faceplugin.faceliveness

import android.content.Intent
import android.graphics.Bitmap
Expand Down Expand Up @@ -27,15 +27,14 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

textWarning = findViewById<TextView>(R.id.textWarning)

// textWarning = findViewById<TextView>(R.id.textWarning)

var ret = FaceSDK.setActivation(
"Nd7j+5R17t1DEkFbd8eXiVMSCdYkHNFMaLDYEMPtJehvdILceeRQDlzpCeOBw0BnyWGCK09XfQDX\n" +
"l3jIeFIi001ynzyleFk5IwA7ZCqnYWBXOCaMfPpd/RUKMKewAdj5q5nbNRzTVIT2v2cir9g6yiNb\n" +
"dav0nX3pLt0q+wB5gyyBZiBcL9Qg2vGeM7F/pN5j0m0v04BVle50GOpn7tIc4Bab+WEC3e9tYAQC\n" +
"adKDtlWrV+wwsmvWtxbtafkohUEW/dGcjURPpQ1TVAj20wfpDdz6HEiXkJQ/jCbaQmg7haB9Pj9+\n" +
"yl9CDAj/THRzoz8C193VhFQG6No8iUFc7w6oCg=="
"f0Y15I2DXE4BP9g3pkGRzcM7HQatMXrQ3B85fFNSb80QJ7txgdrdWpX8EbRjafdCoPBmv3TqeHRc\n" +
"lTIrQBGF7sQUpe2XdEcrkjZgvQBhD4zFlAqMrBvaRaSiGE+LLGa/5XjrOlFpk+1UAlZcPiq+YrBG\n" +
"eS5zDY7FkhPze1q9nsg19yJ7yDFFkCc04ChKcXyNAk8UipYc4CWWx8xnVticyDQI74bdm273kQJw\n" +
"IhL/lwCspEDEVScFycCSIPPTDf3JX3jmZIjcKk8cQjWcPT00/Bly/eYM3KyDk19QXgQ9w86yCL3S\n" +
"kpS91aW3SY7PqVZR2fK56bqxP4dsagSIUJHO6Q=="
)

if (ret == FaceSDK.SDK_SUCCESS) {
Expand All @@ -61,30 +60,30 @@ class MainActivity : AppCompatActivity() {
dbManager.loadPerson()

personAdapter = PersonAdapter(this, DBManager.personList)
val listView: ListView = findViewById<View>(R.id.listPerson) as ListView
listView.setAdapter(personAdapter)

findViewById<Button>(R.id.buttonEnroll).setOnClickListener {
val intent = Intent()
intent.setType("image/*")
intent.setAction(Intent.ACTION_PICK)
startActivityForResult(Intent.createChooser(intent, getString(R.string.select_picture)), SELECT_PHOTO_REQUEST_CODE)
}

// val listView: ListView = findViewById<View>(R.id.listPerson) as ListView
// listView.setAdapter(personAdapter)
//
// findViewById<Button>(R.id.buttonEnroll).setOnClickListener {
// val intent = Intent()
// intent.setType("image/*")
// intent.setAction(Intent.ACTION_PICK)
// startActivityForResult(Intent.createChooser(intent, getString(R.string.select_picture)), SELECT_PHOTO_REQUEST_CODE)
// }
//
findViewById<Button>(R.id.buttonIdentify).setOnClickListener {
startActivity(Intent(this, CameraActivity::class.java))
}

findViewById<Button>(R.id.buttonCapture).setOnClickListener {
startActivity(Intent(this, CaptureActivity::class.java))
}

findViewById<Button>(R.id.buttonAttribute).setOnClickListener {
val intent = Intent()
intent.setType("image/*")
intent.setAction(Intent.ACTION_PICK)
startActivityForResult(Intent.createChooser(intent, getString(R.string.select_picture)), SELECT_ATTRIBUTE_REQUEST_CODE)
}
// findViewById<Button>(R.id.buttonCapture).setOnClickListener {
// startActivity(Intent(this, CaptureActivity::class.java))
// }
//
// findViewById<Button>(R.id.buttonAttribute).setOnClickListener {
// val intent = Intent()
// intent.setType("image/*")
// intent.setAction(Intent.ACTION_PICK)
// startActivityForResult(Intent.createChooser(intent, getString(R.string.select_picture)), SELECT_ATTRIBUTE_REQUEST_CODE)
// }

findViewById<Button>(R.id.buttonSettings).setOnClickListener {
startActivity(Intent(this, SettingsActivity::class.java))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition;
package com.faceplugin.faceliveness;

import android.content.Context;
import android.graphics.Bitmap;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition;
package com.faceplugin.faceliveness;

import android.graphics.Bitmap;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition;
package com.faceplugin.faceliveness;

import android.content.Context;
import android.view.LayoutInflater;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition
package com.faceplugin.faceliveness

import android.graphics.Bitmap
import androidx.appcompat.app.AppCompatActivity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition
package com.faceplugin.faceliveness

import android.content.Context
import android.os.Bundle
Expand Down Expand Up @@ -170,20 +170,20 @@ class SettingsActivity : AppCompatActivity() {
}
}

rollThresholdPref?.setOnPreferenceChangeListener{ preference, newValue ->
val stringPref = newValue as String
try {
if(stringPref.toFloat() < 0.0f || stringPref.toFloat() > 30.0f) {
Toast.makeText(context, getString(R.string.invalid_value), Toast.LENGTH_SHORT).show()
false
} else {
true
}
} catch (e:Exception) {
Toast.makeText(context, getString(R.string.invalid_value), Toast.LENGTH_SHORT).show()
false
}
}
// rollThresholdPref?.setOnPreferenceChangeListener{ preference, newValue ->
// val stringPref = newValue as String
// try {
// if(stringPref.toFloat() < 0.0f || stringPref.toFloat() > 30.0f) {
// Toast.makeText(context, getString(R.string.invalid_value), Toast.LENGTH_SHORT).show()
// false
// } else {
// true
// }
// } catch (e:Exception) {
// Toast.makeText(context, getString(R.string.invalid_value), Toast.LENGTH_SHORT).show()
// false
// }
// }

pitchThresholdPref?.setOnPreferenceChangeListener{ preference, newValue ->
val stringPref = newValue as String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition;
package com.faceplugin.faceliveness;

import androidx.appcompat.app.AppCompatActivity;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faceplugin.facerecognition;
package com.faceplugin.faceliveness;

import android.content.Context;
import android.database.Cursor;
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
android:gravity="center_vertical | left"
android:text="FacePlugin Ltd specializes in cutting-edge solutions including face liveness detection, ID card recognition, face recognition, biometric authentication, and e-KYC (Electronic Know Your Customer) solutions.\n\n
Our solutions cater to a diverse range of industries, including finance, healthcare, retail, transportation, government, and more.\n\n
We are always available to support you here.\n\n\n
Please contact us:"
We are always available to support you here.\n\n\n"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
Expand Down Expand Up @@ -73,7 +72,7 @@ Please contact us:"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="Skype: live:.cid.6f515492327084aa"
android:text="Skype: live:.cid.bd9468a0cefb151d"
app:layout_constraintStart_toEndOf="@id/imageSkype"
app:layout_constraintTop_toTopOf="@id/imageSkype"
app:layout_constraintBottom_toBottomOf="@id/imageSkype"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_camera.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.faceplugin.facerecognition.FaceView
<com.faceplugin.faceliveness.FaceView
android:id="@+id/faceView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</com.faceplugin.facerecognition.FaceView>
</com.faceplugin.faceliveness.FaceView>

</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_camera_kt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
android:layout_height="match_parent">

</io.fotoapparat.view.CameraView>
<com.faceplugin.facerecognition.FaceView
<com.faceplugin.faceliveness.FaceView
android:id="@+id/faceView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</com.faceplugin.facerecognition.FaceView>
</com.faceplugin.faceliveness.FaceView>

</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_capture.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
app:layout_constraintTop_toTopOf="parent" />


<com.faceplugin.facerecognition.CaptureView
<com.faceplugin.faceliveness.CaptureView
android:id="@+id/captureView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</com.faceplugin.facerecognition.CaptureView>
</com.faceplugin.faceliveness.CaptureView>

<TextView
android:id="@+id/textTitle"
Expand Down
Loading

0 comments on commit 69c8580

Please sign in to comment.