Auto Selfie Capture
Auto Selfie Capture provides you with an UI Fragment configurations that allow the user's selfie to be taken automatically. In this module, if the selfie cannot be taken after the given time, it offers a way to capture the selfie with a press of a button. The main difference between the Auto Selfie Capture and Manual Selfie Capture is it provides a real-time tracking of faces on the screen while checking the face is in the desired dimensions and distance.
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
User Interface Settings
Before calling the start()
method, you can adjust some settings releated to
Auto Selfie Capture fragment. To do this, use the ASCBuilder
class.
// preparing the user interface.
val ascBuilder = ASCBuilder(
R.color.color_black, // Text color of message
20, // Text size of message
R.color.any_color, // Text color of counter animation.
true, // Counter visibility as boo
100, // Counter text size (It should be proportional to the screen size. As a proper usage: getScreenHeight()/10)
20, // Manual capture button time out as second.
"Be sure to be close enough", // Message texts
"Face not found", // Message texts
"Hold stable, while taking photo", // Message texts
"Failed, process will restart in 3 seconds", // Message texts
R.color.any_color2, // Oval view color
R.color.any_color3) // Success animate color
Getting the fragment
Now you can call the actual start()
method with the ASCBuilder
you've just created.
Amani.sharedInstance()
.AutoSelfieCapture()
.start(
docType = "type_of_document: XXX_SE_0",
ascBuilder = ascBuilder,
frameLayout = frameLayout,
object : IFragmentCallback {
override fun cb(bitmap: Bitmap?, manualButtonActivated: Boolean?, file: File?) {
// Capture is successfull if bitmap is not null
}
}
)
// navigating the created fragment view
fragment?.let {
replaceFragmentWithBackStack(R.id.frame_auto_selfie, it)
}
Uploading the Captured Selfie
The upload method has to be called after the result of the start method is successful, otherwise you'll encounter with an error in the Errors()
object when called.
//Uploading the current taken Selfie data
Amani.sharedInstance()
.AutoSelfieCapture()
.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
}
}
)