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