Skip to content

Commit 192cff5

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 611a49e + e78560d commit 192cff5

2 files changed

Lines changed: 75 additions & 42 deletions

File tree

README.md

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ Then, add the library dependency to your app's build.gradle file:
3232

3333
```gradle
3434
dependencies {
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
6769
fun 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

docs/index.html

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,9 @@ <h4>Add JitPack Repository</h4>
430430
<div class="col-md-6">
431431
<h4>Add Dependency</h4>
432432
<pre class="code-block"><code>dependencies {
433-
implementation 'com.github.arya458:FaceVerification:1.0.0'
433+
implementation("com.github.arya458:FaceVerification:1.0.0")
434+
implementation("com.google.mlkit:face-detection:16.1.7")
435+
434436
}</code></pre>
435437
</div>
436438
</div>
@@ -442,22 +444,43 @@ <h2 class="text-center mb-5">Usage</h2>
442444
<div class="row">
443445
<div class="col-12">
444446
<pre class="code-block"><code>@Composable
445-
fun MyVerificationScreen() {
446-
val context = LocalContext.current
447+
val context = LocalContext.current
447448
val faceDetectionCallback = remember {
448-
object : FaceVerificationComponent.FaceDetectionCallback {
449-
override fun onOneFaceDetected(imageProxy: ImageProxy) {
450-
// Handle face detection
451-
val base64Image = imageProxyToBase64(imageProxy)
452-
// Process the image
453-
}
454-
}
455-
}
456-
457-
FaceVerificationComponent(
458-
context = context,
459-
faceDetectionCallback = faceDetectionCallback
460-
)
449+
object : FaceDetectionCallback {
450+
override fun onManyFacesDetected(
451+
faces: List<Face?>,
452+
imageProxy: ImageProxy
453+
) {
454+
}
455+
456+
override fun onOneFaceDetected(face: Face, imageProxy: ImageProxy) {
457+
// One face detected! Process the imageProxy here.
458+
val base64Image = imageProxyToBase64(imageProxy)
459+
base64Image?.let {
460+
android.util.Log.d("FaceVerification", "Base64 Image (first 50 chars): ${it.substring(0, 50)}...")
461+
// Send to your verification backend or process locally
462+
}
463+
imageProxy.close() // Remember to close the ImageProxy
464+
}
465+
466+
override fun onFaceDetectionError(exception: Exception) {
467+
}
468+
469+
override fun onNoFaceDetected(imageProxy: ImageProxy) {
470+
android.util.Log.d("FaceVerification", "No face detected")
471+
// Handle no face detected scenario
472+
}
473+
}
474+
}
475+
476+
477+
FaceVerificationComponent(
478+
onSmile = {},
479+
onFaceDetected = {},
480+
onFacesDetected = {},
481+
noFaceDetected = {},
482+
onError = {}
483+
)
461484
}</code></pre>
462485
</div>
463486
</div>
@@ -539,4 +562,4 @@ <h5 class="card-title">Submit PRs</h5>
539562
});
540563
</script>
541564
</body>
542-
</html>
565+
</html>

0 commit comments

Comments
 (0)