Skip to content

Commit

Permalink
Refactoring and Some feature update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu-j-faceonlive committed Jan 12, 2022
1 parent a7e2256 commit 0dba89b
Show file tree
Hide file tree
Showing 82 changed files with 1,506 additions and 1,016 deletions.
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,41 @@

An App Made with Face SDK

<img src="cover_image.png">

## Getting Started

<img src="cover_image.png">
## Features
- Attendance management with ease
- Get attendance with face verification
- Fast Face Verification
- Use it as Static device to verify multiple person
- Add a member without in need of another app in their phone
- Multiple Space with seperate attendance on each of them
- Attendance filtering
- Holiday Changing
- Dark Mode
- Member Login
- Admin Login
- Admin managment
- Add Member with qr code
- Join Space with qr code
- ~~Face Login in the app~~ [Coming Soon]
- ~~Daily log and notification~~ [Can be added with cloud functions]
- Space Range Selection [Admin Side]
- ~~ Geolocation based verification ~~ [Coming Soon]

### IF you face plugin error:
- STEP_1: Comment custom camera kit plugin from pubspec.yaml and run flutter pub get
- STEP_2: Add These lines in **"android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java"**

``` java
import com.ttv.attendance.CamerakitPlugin;

try {
flutterEngine.getPlugins().add(new CamerakitPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin camera, io.flutter.plugins.camera.CameraPlugin", e);
}
```
- STEP_3: Uncomment custom camera kit plugin and run flutter pub get
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.abdulmomin.face_attendance"
applicationId "com.ttv.faceattendance"
minSdkVersion 23
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
Expand Down
13 changes: 3 additions & 10 deletions android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
{
"project_info": {
"project_number": "806724864097",
"firebase_url": "https://face-attendance-dcec9-default-rtdb.firebaseio.com",
"project_id": "face-attendance-dcec9",
"storage_bucket": "face-attendance-dcec9.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:806724864097:android:18f53fce2aa9ad83c90220",
"mobilesdk_app_id": "1:806724864097:android:b8bac05c56fda859c90220",
"android_client_info": {
"package_name": "com.abdulmomin.face_attendance"
"package_name": "com.ttv.faceattendance"
}
},
"oauth_client": [
{
"client_id": "806724864097-b7gpf62kd0jiqfvv0f8uuqi2jgqbq2g5.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.abdulmomin.face_attendance",
"certificate_hash": "aba0cf0e4e81e65bc6931db76e321d3974e42218"
}
},
{
"client_id": "806724864097-3tuidlb9q49d1dt7fugeo1ueu0t15h8u.apps.googleusercontent.com",
"client_type": 3
Expand Down
Binary file modified android/app/libs/ttvface.aar
Binary file not shown.
2 changes: 1 addition & 1 deletion android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abdulmomin.face_attendance">
package="com.ttv.faceattendance">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
4 changes: 2 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abdulmomin.face_attendance">
package="com.ttv.faceattendance">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:label="Turing Tech"
android:label="FaceOnLive"
android:icon="@mipmap/ic_launcher">
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyAT7wzBH5AWw_GpYTnNjXCO_DuhQr3_4zs"/>
Expand Down

This file was deleted.

118 changes: 118 additions & 0 deletions android/app/src/main/kotlin/com/ttv/faceattendance/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package com.ttv.faceattendance
import io.flutter.embedding.android.FlutterActivity
import androidx.annotation.NonNull
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import android.util.Log
import android.content.Context
import android.graphics.BitmapFactory
import com.ttv.attendance.CamerakitPlugin
import com.ttv.face.*

class MainActivity: FlutterActivity() {

private val channelName = "turingtech"
private var appCtx: Context?= null

init {
appCtx = this
}

override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
flutterEngine.plugins.add(CamerakitPlugin())
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, channelName).setMethodCallHandler {
call, result ->

// <--- METHOD: Verify Against All Picture --->
when (call.method) {
"setDatabase" -> {
val memberList : HashMap<Int, ByteArray>? = call.argument("membersList")
/// Should Call everytime the app starts
/// This will set the database of faces

FaceEngine.getInstance(this).removeFaceFeature(-1)
for ((key, value) in memberList!!) {
val faceFeatureInfo =
FaceFeatureInfo(key, value)

FaceEngine.getInstance(this).registerFaceFeature(faceFeatureInfo)
}
// Do verification and
// Put the verified user id in this variable
result.success(true)
}

// <--- METHOD: Verify Single Person --->
"verifySinglePerson" -> {
val personImage : ByteArray? = call.argument("personImage")
val capturedImage: ByteArray? = call.argument("capturedImage")

// You can verify this 1to1 and put your result in this
var isThisPersonVerified = false

val image1 = BitmapFactory.decodeByteArray(personImage!!, 0, personImage.size)
if(image1 != null) {
val faceResults1:List<FaceResult> = FaceEngine.getInstance(this).detectFace(image1)
if(faceResults1.count() == 1) {
FaceEngine.getInstance(this).extractFeature(image1, true, faceResults1)

val image2 = BitmapFactory.decodeByteArray(capturedImage!!, 0, capturedImage.size)
val faceResults2:List<FaceResult> = FaceEngine.getInstance(this).detectFace(image2)
if(faceResults2.count() == 1) {
FaceEngine.getInstance(this).extractFeature(image2, false, faceResults2)
val face1 = faceResults1[0].feature
val face2 = faceResults2[0].feature
val score = FaceEngine.getInstance(this).compareFeature(face1, face2)
if(score > 0.82) {
Log.e("ddd", "The score is")
Log.e("ddd",score.toString())
isThisPersonVerified = true
}
}
}
}

result.success(isThisPersonVerified)

}
"initSDK" -> {
Log.e("ddd", "init SDK!!!!")

FaceEngine.getInstance(this).setActivation("")
FaceEngine.getInstance(this).init(1)

Log.e("ddd", "init ok!!!")

result.success(true)
}
"getFeature" -> {
Log.e("ddd", "getFeature!!!!")

var feat:ByteArray? = null
val capturedImage: ByteArray? = call.argument("image")
// val mode:Int? = call.argument("mode")
if(capturedImage != null) {
val image = BitmapFactory.decodeByteArray(capturedImage, 0, capturedImage.size)
val faceResults: List<FaceResult> = FaceEngine.getInstance(this).detectFace(image)
if (faceResults.count() == 1) {
FaceEngine.getInstance(this).extractFeature(image, true, faceResults)

feat = faceResults[0].feature

// val faceFeatureInfo =
// FaceFeatureInfo(1, feat)
// FaceEngine.getInstance(this).registerFaceFeature(faceFeatureInfo)
}
}

result.success(feat)
}
else -> {
result.notImplemented()
}
}

}
}
}
Binary file modified android/app/src/main/res/mipmap-hdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-hdpi/launch_image.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/launch_image.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/launch_image.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxhdpi/launch_image.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxxhdpi/launch_image.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abdulmomin.face_attendance">
package="com.ttv.faceattendance">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
Binary file modified assets/images/logos/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/logos/logo_without_title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions firestore.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
rules_version = '2';
service cloud.firestore {

function isSignedIn(){
return request.auth != null;
}

// If the requests match the request of Admin request
function isRequestsFieldValid(){
return request.resource.data.keys().hasOnly(
['name', 'companyName', 'extraInfo', 'email', 'idToken']);
}

match /databases/{database}/documents {
match /{document=**} {
/// This is only for debugging the final version will contain all the security rules;
allow read, write: if isSignedIn();
}



match /meta_data/admin_requests/the_requests/{requests}{
allow write: if isRequestsFieldValid();
}

}
}
Loading

0 comments on commit 0dba89b

Please sign in to comment.