-
Notifications
You must be signed in to change notification settings - Fork 2
Project restructuring for Sample app #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ee4e32e
Move SimFace code into a dedicate module
luhmirin-s 0b8d42b
Move the sample app into the main repository
luhmirin-s d0bc21a
Refactor the sample app according to compose best practices
luhmirin-s b869b12
Split test image and camera demos into separate screens
luhmirin-s eb05c82
Minor manual cleanup
luhmirin-s d61bcd4
Split UI state per screen
luhmirin-s ad850e5
Split view models per main screen
luhmirin-s 256f3c1
Fully separate demo logic per screen
luhmirin-s 883338b
Update documentation by fixing inconsistencies and adding new sections
luhmirin-s 8920603
Resolve minor issues in CameraPreviewScreen
luhmirin-s File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,4 +30,4 @@ jobs: | |
| java-version: '17' | ||
|
|
||
| - name: Build with Gradle | ||
| run: ./gradlew build | ||
| run: ./gradlew simface:build | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| # SimFace | ||
| # Simprints Face Biometrics SDK | ||
|
|
||
| ## SimFace Library | ||
|
|
||
| An Android library for face recognition and quality assessment on edge devices. | ||
| It provides face detection, embedding creation, and biometric matching capabilities. | ||
|
|
@@ -9,15 +11,17 @@ detection and [EdgeFace](https://github.com/otroshi/edgeface) for embedding (tem | |
| 2. Embedding Creation: This module is used to generate a 512-float vector representation of face images. | ||
| 3. Matching and Identification: Used for verification and identification purposes. | ||
|
|
||
| **📚 [View Full Documentation](simface/README.md)** for installation and usage examples. | ||
|
|
||
| ## SimQ Library | ||
|
|
||
| **SimQ** is a standalone Android library for comprehensive face quality assessment. It can be used independently or as part of SimFace for enhanced quality evaluation. SimQ provides a quality score from 0.0 to 1.0, with customizable weights for each metric and configurable thresholds. | ||
| **SimQ** is a standalone Android library for comprehensive face quality assessment. It can be used independently or as part of SimFace for | ||
| enhanced quality evaluation. SimQ provides a quality score from 0.0 to 1.0, with customizable weights for each metric and configurable | ||
| thresholds. | ||
|
|
||
| **📚 [View Full SimQ Documentation](simq/README.md)** for installation, usage examples, and advanced configuration options. | ||
|
|
||
| ## Include the library into the project. | ||
|
|
||
| ### Option 1 (Recommended) | ||
| ### Installation | ||
|
|
||
| 1. Add the repository to your `settings.gradle.kts` under `dependencyResolutionManagement` under `respositories`: | ||
|
|
||
|
|
@@ -31,99 +35,19 @@ maven { | |
| } | ||
| ``` | ||
|
|
||
| 2. Import the dependencies in `build.gradle.kts`: | ||
| Import the dependencies in `build.gradle.kts`: | ||
|
|
||
| ```kotlin | ||
| // To add the full Biometric SDK | ||
| implementation("com.simprints.biometrics:simface:2026.1.0") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this import both simface and simq?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SimQ is added transitively, so this will add both. |
||
| ``` | ||
|
|
||
| ## Implement the functionality. | ||
|
|
||
| ### Coroutines (Recommended) | ||
|
|
||
| ```kotlin | ||
| // Initialize library configuration | ||
| val simFace = SimFace() | ||
| val simFaceConfig = SimFaceConfig(context) | ||
| simFace.initialize(simFaceConfig) | ||
|
|
||
| // Load a bitmap image for processing | ||
| val faceImage: Bitmap = | ||
| BitmapFactory.decodeResource(context.resources, R.drawable.royalty_free_good_face) | ||
|
|
||
| lifecycleScope.launch { | ||
| val faces = simFace.detectFaceBlocking(faceImage) | ||
| val face = faces[0] | ||
| if (faces.size != 1 || face.quality < 0.6) throw Exception("Quality not sufficient") | ||
|
|
||
| // Align and crop the image of the face | ||
| val alignedFace = face.alignedFaceImage(bitmap) | ||
|
|
||
| // Generate an embedding from the image | ||
| val probe = simFace.getFaceDetectionProcessor().getEmbedding(alignedFace) | ||
|
|
||
| // Verify the embedding against itself | ||
| val score = simFace.verificationScore(probe, probe) | ||
| } | ||
| // Or if only quality assessment is needed | ||
| implementation("com.simprints.biometrics:simq:2026.1.0") | ||
| ``` | ||
|
|
||
| ### Callbacks | ||
|
|
||
| ```kotlin | ||
| // Initialize library configuration | ||
| val simFace = SimFace() | ||
| val simFaceConfig = SimFaceConfig(context) | ||
| simFace.initialize(simFaceConfig) | ||
|
|
||
| // Load a bitmap image for processing | ||
| val faceImage: Bitmap = BitmapFactory.decodeResource(context.resources, R.drawable.royalty_free_good_face) | ||
|
|
||
| // Note that this can be better handled with callbacks or coroutines | ||
| simFace.getFaceDetectionProcessor().detectFace(faceImage, onSuccess = { faces -> | ||
| val face = faces[0] | ||
| if (faces.size != 1 || face.quality < 0.6) throw Exception("Quality not sufficient") | ||
|
|
||
| // Align and crop the image of the face | ||
| val alignedFace = face.alignedFaceImage(bitmap) | ||
|
|
||
| // Generate an embedding from the image | ||
| val probe = simFace.getEmbedding(alignedFace) | ||
|
|
||
| // Verify the embedding against itself | ||
| val score = simFace.verificationScore(probe, probe) | ||
| }) | ||
| ``` | ||
|
|
||
| ## Workflow | ||
|
|
||
| ### Face Detection and Embedding | ||
|
|
||
| We first initialize the library. Then we can use the | ||
| `simFace.detectFace` method to detect faces in images and evaluate their quality. | ||
| We can repeat this process multiple times until a sufficiently good face image is selected. | ||
|
|
||
| Afterwards, we can use the `simFace.getEmbedding` method to obtain a vector template | ||
| from the selected image. The embedding is represented by a 512 float array. | ||
|
|
||
| ### Verification and Identification | ||
|
|
||
| The same steps are taken to initialize the library. | ||
|
|
||
| Then, the matching of two templates is carried out using the `simFace.verificationScore` method, | ||
| which returns a score in the [0, 1] range, being 1 a perfect match. | ||
|
|
||
| Identification can be carried using the `simFace.identificationScore` method which returns a mapping of the | ||
| referenceVectors to the the score with respect to the probe. | ||
|
|
||
| Both methods use the cosine similarity between vectors as a measure of the score. | ||
|
|
||
| ## System Requirements | ||
| ### SimFace Demo app | ||
|
|
||
| The library works with a minimum version of Android 6.0 (API Level 23). It has been tested and runs | ||
| smoothly on _Samsung Galaxy A03 Core_ which has the following specifications: | ||
| The `sample` module demonstrates end-to-end usage of SimFace APIs in a minimal app. | ||
| It is intended as a reference implementation for integration and testing. | ||
|
|
||
| - Android 11 | ||
| - 1.6GHz Octa-core | ||
| - 2GB RAM | ||
| - 8MP f/2.0 Camera | ||
| - 32GB Storage | ||
| Usage: Open the repository in Android Studio and run the `sample` module. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,91 +1,6 @@ | ||
| plugins { | ||
| alias(libs.plugins.android.library) | ||
| alias(libs.plugins.jetbrains.kotlin.android) | ||
| `maven-publish` | ||
| alias(libs.plugins.android.application) apply false | ||
| alias(libs.plugins.android.library) apply false | ||
| alias(libs.plugins.kotlin.compose) apply false | ||
| } | ||
|
|
||
| val projectGroupId = "com.simprints.biometrics" | ||
| val projectArtifactId = "simface" | ||
| val projectVersion = "2026.1.0" | ||
|
|
||
| group = projectGroupId | ||
| version = projectVersion | ||
|
|
||
| android { | ||
|
|
||
| namespace = "$projectGroupId.$projectArtifactId" | ||
| compileSdk = 36 | ||
|
|
||
| defaultConfig { | ||
| minSdk = 23 | ||
|
|
||
| testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
| } | ||
|
|
||
| buildTypes { | ||
| release { | ||
| isMinifyEnabled = false | ||
| proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt")) | ||
| } | ||
| } | ||
| compileOptions { | ||
| sourceCompatibility = JavaVersion.VERSION_17 | ||
| targetCompatibility = JavaVersion.VERSION_17 | ||
| } | ||
| kotlinOptions { | ||
| jvmTarget = "17" | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| api(project(":simq")) | ||
|
|
||
| // Tensorflow versions that works with Edgeface | ||
| api(libs.tensorflow.lite.support) | ||
| api(libs.tensorflow.lite.metadata) | ||
| api(libs.tensorflow.lite) | ||
|
|
||
| // Face Detection and quality | ||
| api(libs.face.detection) | ||
|
|
||
| // For face alignment | ||
| api(libs.ejml.simple) | ||
|
|
||
| androidTestImplementation(libs.truth) | ||
| androidTestImplementation(libs.androidx.junit) | ||
| androidTestImplementation(libs.androidx.espresso.core) | ||
| androidTestImplementation(libs.kotlinx.coroutines.test) | ||
| } | ||
|
|
||
| publishing { | ||
| repositories { | ||
| maven { | ||
| name = "GitHubPackages" | ||
| url = uri("https://maven.pkg.github.com/simprints/Biometrics-SimFace") | ||
| credentials { | ||
| username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME") | ||
| password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN") | ||
| } | ||
| } | ||
| } | ||
| publications { | ||
| create<MavenPublication>("ReleaseAar") { | ||
| groupId = projectGroupId | ||
| artifactId = projectArtifactId | ||
| version = projectVersion | ||
| afterEvaluate { artifact(tasks.getByName("bundleReleaseAar")) } | ||
|
|
||
| pom.withXml { | ||
| val dependenciesNode = asNode().appendNode("dependencies") | ||
|
|
||
| configurations.getByName("api").dependencies.map { dependency -> | ||
| dependenciesNode.appendNode("dependency").also { | ||
| it.appendNode("groupId", dependency.group) | ||
| it.appendNode("artifactId", dependency.name) | ||
| it.appendNode("version", dependency.version) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| #Thu Oct 02 14:49:35 EEST 2025 | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.