Auto Selfie
Changing the colors on Android
You must add a resource file on Android for AutoSelfie colors. You can find the keys in the example below.
To create this file, open the project on Android Studio right click on the res
directory and create new Android Resource file. While creating select the "Resource Type" to values.
After that modify the file as shown below. note: pose estimation module has different set of keys that you can add. If you want to use pose estimation while using the auto selfie merge the files.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="auto_selfie_text">#000000</color>
<color name="auto_selfie_counter_text">#000000</color>
<color name="auto_selfie_oval_view">#000000</color>
<color name="auto_selfie_success_anim">#000000</color>
</resources>
Auto selfie usage
Get the auto selfie module from the main AmaniSDK
instance which you have previously initialized.
// Configure the AutoSelfie
final IOSAutoSelfieSettings _iOSAutoSelfieSettings = IOSAutoSelfieSettings(
faceIsOk: "Please hold stable",
notInArea: "Please align your face with the area",
faceTooSmall: "Your face is in too far",
faceTooBig: "Your face is in too close",
completed: "All OK!",
appBackgroundColor: "000000",
appFontColor: "ffffff",
primaryButtonBackgroundColor: "ffffff",
ovalBorderSuccessColor: "00ff00",
ovalBorderColor: "ffffff",
countTimer: "3",
manualCropTimeout: 30);
final AndroidAutoSelfieSettings _androidAutoSelfieSettings =
AndroidAutoSelfieSettings(
textSize: 16,
counterVisible: true,
counterTextSize: 21,
manualCropTimeout: 30,
distanceText: "Please align your face with the area",
faceNotFoundText: "No faces found",
restartText: "Process failed, restarting...",
stableText: "Please hold stable");
// Since the platform plugins are async, you must create this function
Future<void> initAutoSelfie() async {
var selfie = AmaniSDK().getAutoSelfie();
await selfie.setType("XXX_SE_0");
}
//And call it here.
void initState() {
super.initState();
initAutoSelfie();
}
Later on the buttons onPressed
onPressed: () async {
final Uint8List imageData =
await AmaniSDK().getAutoSelfie().start(
iosAutoSelfieSettings: _iOSAutoSelfieSettings,
androidAutoSelfieSettings: _androidAutoSelfieSettings,
);
// Do something with imageData
setState(() {
_imageData = imageData;
});
},