Skip to main content

Pose Estimation 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: auto selfie 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="pose_estimation_oval_view_start">#000000</color>
<color name="pose_estimation_oval_view_success">#000000</color>
<color name="pose_estimation_oval_view_error">#000000</color>
<color name="pose_estimation_alert_title">#000000</color>
<color name="pose_estimation_alert_description">#000000</color>
<color name="pose_estimation_alert_try_again">#000000</color>
<color name="pose_estimation_alert_background">#000000</color>
<color name="pose_estimation_font">#000000</color>
</resources>

Changing the guide images on Android

Open the android studio and add your images with following names. The SDK will automatically use the new images for guide images.

Secondary guide images shows up at bottom, while the main guide images shows in the center of the oval view.

keydescription
pose_estimation_main_guide_leftMain Guide (left)
pose_estimation_main_guide_rightMain Guide (right)
pose_estimation_main_guide_upMain Guide (up)
pose_estimation_main_guide_downMain Guide (down)
pose_estimation_main_guide_straightMain Guide (straight)
pose_estimation_secondary_guide_leftSecondary Guide (left)
pose_estimation_secondary_guide_rightSecondary Guide (right)
pose_estimation_secondary_guide_upSecondary Guide (up)
pose_estimation_secondary_guide_downSecondary Guide (down)

Pose estimation usage

Get the pose estimation module from the main AmaniSDK instance which you have previously initialized.


// Configure the pose estimation
// NOTE: Colors and images are adjusted via resource files on android studio
final AndroidPoseEstimationSettings _androidPoseEstimationSettings =
AndroidPoseEstimationSettings(
poseCount: 3,
animationDuration: 500,
faceNotInside: "Your face is not inside the area",
faceNotStraight: "Your face is not straight",
faceIsTooFar: "Your face is too far",
holdPhoneVertically: "Please hold stable",
alertTitle: "Verification Failed",
alertDescription: "Failed 1",
alertTryAgain: "Try again",
turnRight: "→",
turnLeft: "←",
turnUp: "↑",
turnDown: "↓",
lookStraight: "Look straight",
mainGuideVisibility: true,
secondaryGuideVisibility: true,
);

final IOSPoseEstimationSettings _iosPoseEstimationSettings =
IOSPoseEstimationSettings(
faceIsOk: "Please hold stable",
notInArea: "Please align your face to the area",
faceTooSmall: "Your face is in too far",
faceTooBig: "Your face is in too close",
completed: "Verification Completed",
turnRight: "→",
turnLeft: "←",
turnUp: "↑",
turnDown: "↓",
lookStraight: "Look straight",
errorMessage:
"Please complete the steps while your face is aligned to the area",
tryAgain: "Try again",
errorTitle: "Verification Failure",
confirm: "Confirm",
next: "Next",
holdPhoneVertically: "Please hold the phone straight",
informationScreenDesc1:
"To start verification, align your face with the area",
informationScreenDesc2: "",
informationScreenTitle: "Selfie Verification Instructions",
wrongPose: "Your face must be straight",
descriptionHeader:
"Please make sure you are doing the correct pose and your face is aligned with the area",
appBackgroundColor: "000000",
appFontColor: "ffffff",
primaryButtonBackgroundColor: "ffffff",
primaryButtonTextColor: "000000",
ovalBorderColor: "ffffff",
ovalBorderSuccessColor: "00ff00",
poseCount: "3",
mainGuideVisibility: "true",
buttonRadious: "10",
manualCropTimeout: 30,
);
// Since the platform plugins are async, you must create this function
Future<void> initPoseEstimation() async {
var selfie = AmaniSDK().getPoseEstimation();
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 _flutterAmanisdkV2Plugin
.getPoseEstimation()
.start(androidSettings: _androidPoseEstimationSettings, iosSettings: _iosPoseEstimationSettings);
// Do something with imageData
setState(() {
_imageData = imageData;
});
},

Video recording the capture process

We can record the capture process.

To use this feature just call setVideoRecording method.

await AmaniSDK().getPoseEstimation().setVideoRecording(true);