@@ -32,7 +32,9 @@ Then, add the library dependency to your app's build.gradle file:
3232
3333``` gradle
3434dependencies {
35- implementation 'com.github.arya458:AndroidFaceVerificationLibrary:1.0.0' // Replace with the latest version
35+ implementation("com.github.arya458:AndroidFaceVerificationLibrary:1.0.0") // Replace with the latest version
36+ implementation("com.google.mlkit:face-detection:16.1.7")
37+
3638 // ... other dependencies
3739}
3840```
@@ -67,33 +69,41 @@ import com.aria.danesh.faceverificationlib.utils.ImageProxyHelperKt.imageProxyTo
6769fun MyVerificationScreen () {
6870 val context = LocalContext .current
6971 val faceDetectionCallback = remember {
70- object : FaceVerificationComponent .FaceDetectionCallback {
71- override fun onOneFaceDetected (imageProxy : androidx.camera.core.ImageProxy ) {
72- // One face detected! Process the imageProxy here.
73- val base64Image = imageProxyToBase64(imageProxy)
74- base64Image?.let {
75- android.util.Log .d(" FaceVerification" , " Base64 Image (first 50 chars): ${it.substring(0 , 50 )} ..." )
76- // Send to your verification backend or process locally
72+ object : FaceDetectionCallback {
73+ override fun onManyFacesDetected (
74+ faces : List <Face ?>,
75+ imageProxy : ImageProxy
76+ ) {
77+ }
78+
79+ override fun onOneFaceDetected (face : Face , imageProxy : ImageProxy ) {
80+ // One face detected! Process the imageProxy here.
81+ val base64Image = imageProxyToBase64(imageProxy)
82+ base64Image?.let {
83+ android.util.Log .d(" FaceVerification" , " Base64 Image (first 50 chars): ${it.substring(0 , 50 )} ..." )
84+ // Send to your verification backend or process locally
85+ }
86+ imageProxy.close() // Remember to close the ImageProxy
87+ }
88+
89+ override fun onFaceDetectionError (exception : Exception ) {
90+ }
91+
92+ override fun onNoFaceDetected (imageProxy : ImageProxy ) {
93+ android.util.Log .d(" FaceVerification" , " No face detected" )
94+ // Handle no face detected scenario
95+ }
96+ }
7797 }
78- imageProxy.close() // Remember to close the ImageProxy
79- }
80-
81- override fun onNoFaceDetected () {
82- android.util.Log .d(" FaceVerification" , " No face detected" )
83- // Handle no face detected scenario
84- }
8598
86- override fun onMultipleFacesDetected () {
87- android.util.Log .d(" FaceVerification" , " Multiple faces detected" )
88- // Handle multiple faces detected scenario
89- }
90- }
91- }
9299
93- FaceVerificationComponent (
94- context = context,
95- faceDetectionCallback = faceDetectionCallback
96- )
100+ FaceVerificationComponent (
101+ onSmile = {},
102+ onFaceDetected = {},
103+ onFacesDetected = {},
104+ noFaceDetected = {},
105+ onError = {}
106+ )
97107}
98108```
99109
0 commit comments