Selfie Pose Estimation Capture
Pose Estimation selfie creates a fragment that asks the user for random and certain number of head movements and confirms them with the customer observer pattern.
caution
In order to use this module, the noCompress
option for tflite
files must be set as shown below. Otherwise you'll get a compile errors.
aaptOptions {
noCompress "tflite"
}
Starting the Capture
Creating the PoseEstimationObserver
Before calling the Builder()
you must create the PoseEstimationObserver
to capture the events emmited from this module.
// Creating the observer to observe PoseEstimation events
private val observer: PoseEstimationObserver = object : PoseEstimationObserver {
override fun onSuccess(bitmap: Bitmap?) {
// If bitmap is not null, selfie is taken successfully.
// The upload function can be called.
}
override fun onFailure(reason: OnFailurePoseEstimation, currentAttempt: Int) {
//Current pose is failed the reason is here
}
override fun onError(error: Error) {
//General exception during the process
}
}
Building the Fragment
You can configure this module while creating the Fragment
by using the
included Builder()
method.
val fragment = Amani.sharedInstance().SelfiePoseEstimation()
.Builder()
.requestedPoseNumber(1) //The amount of the random poses
.videoRecord(videoRecord = true) //Enables the video record
.ovalViewAnimationDurationMilSec(500)
.observe(observer)
.userInterfaceColors(
R.color.white,
R.color.approve_green,
R.color.error_red,
R.color.color_white,
R.color.white,
R.color.white,
R.color.color_pink,
R.color.white)
.userInterfaceTexts(
"Your face is not inside the area",
"Your face is not straight",
"Your face is too far from camera",
"Please keep straight the phone",
"Verification Failed",
"Failed",
"Try Again"
)
.build(this)
Starting the Fragment
You can navigate the fragment as shown below.
fragment?.let {
navigateToFragmentMethod(it)
}
Uploading the Captured Selfie
caution
The upload method has to be called after the result of the observer is successful. Otherwise you'll encounter an error in the Errors()
object as a result.
Amani.sharedInstance()
.SelfiePoseEstimation()
.upload(
requireContext(),
"type_of_document example: XXX_SE_0",
object : IUploadCallBack{
override fun cb(
isSuccess: Boolean
) {
//isSuccess means the Selfie Data is uploaded
//result is the result of uploaded document it should be equal "OK"
// if the current Selfie has no error
//If Selfie has errors, errors object will not be null anymore
}
}
)