With Viola Age classification library, you can find age range of a given face bitmap.
Demo application
Download sample application sample_v_1.0.2
Compatibility
- Minimum Android SDK : Viola Age 1.0.2 requires a minimum API level of 21.
Installation
Download the latest aar from jitpack or grab via
root build.gradle:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
app build.gradle:
dependencies {
implementation 'com.github.darwinfrancis:viola-age:1.0.2'
}
or Maven:
<dependency>
<groupId>com.github.darwinfrancis</groupId>
<artifactId>viola-age</artifactId>
<version>1.0.2</version>
<type>pom</type>
</dependency>
Kotlin
val violaAgeClassifier = ViolaAgeClassifier(listener)
violaAgeClassifier.findAgeAsync(bitmap) //asynchronous call using callback interface
private val listener: AgeClassificationListener = object : AgeClassificationListener {
override fun onAgeClassificationResult(result: List<AgeRecognition>) {}
override fun onAgeClassificationError(error: String) {}
}
//OR using synchronous function call
val result:List<AgeRecognition> = violaAgeClassifier.findAgeSynchronized(faceBitmap) //synchronous call
with AgeOptions
val ageOption =
AgeOptions.Builder()
.enableFacePreValidation()
.build()
violaAgeClassifier.findAgeAsync(bitmap,ageOption)
Java
ViolaAgeClassifier violaAgeClassifier = new ViolaAgeClassifier(listener);
violaAgeClassifier.findAgeAsync(bitmap); //asynchronous call using callback interface
private final AgeClassificationListener listener = new AgeClassificationListener() {
@Override
public void onAgeClassificationResult(@NotNull List<AgeRecognition> result) { }
@Override
public void onAgeClassificationError(@NotNull String error) { }
};
//OR using synchronous function call
List<AgeRecognition> result = violaAgeClassifier.findAgeSynchronized(faceBitmap); //synchronous call
with AgeOptions
AgeOptions ageOption = new AgeOptions.Builder()
.enableFacePreValidation()
.build();
violaAgeClassifier.findAgeAsync(bitmap,ageOption)
Viola age-classifier is currently extended with the following configurations. Instructions on how to use them in your own application are linked below.
AgeOptions | Description | Type | Default |
---|---|---|---|
preValidateFace |
Indicates whether to validate face presence before age classification (ignore this if input image has valid face in it.) | boolean | false |
Viola Age Classification provides the following values in Result class
Result | Description | Type |
---|---|---|
result |
age recognition result list | AgeRecognition |
Darwin Francis - @darwinfrancis on GitHub, @darwin-francis on linkedin
Viola-Face face detection and crop library for android.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
MIT License
Copyright (c) 2020 Darwin Francis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.