Physical ID Card Capture
The physical ID Capture introduces a way to capture photos of physical ID documents

Steps to implementation

Step 1

In your layout file add the SmartCardView. We advise on giving the view as much real estate as possible so match parent on both height and width is advisable
1
<com.smileidentity.libsmileid.core.idcapture.SmartCardView
2
android:id="@+id/id_capture"
3
android:layout_width="match_parent"
4
android:layout_height="match_parent"
5
<!--optional fields for customisation-->
6
xmlns:app="http://schemas.android.com/apk/res-auto"
7
app:faceDetectedMessage="Custom face detected message"
8
app:blurryMessage="Custom message for when capture is blurry"
9
app:insufficientLightMessage="Custom message for when there is insufficient light"
10
app:fitIdMessage="Custom message informing the user to fit the id on the rectangle and tap for focus"
11
app:flashMissingErrorMessage="Custom flash missing error message"
12
app:loadingMessage="Custom message for when ID capture is loading"
13
app:detectingFaceMessage="Custom message for when ID capture face detection is in progress"
14
app:noFaceDetectedMessage="Custom no face detected message"
15
>
16
</com.smileidentity.libsmileid.core.idcapture.SmartCardView>
Copied!

Step 2

Initialize the view in your view controller as normal and set the listener so that the SDK can pass back information on the capture
1
SmartCardView smartCardView = findViewById(R.id.id_capture);
2
smartCardView.setListener(this);
Copied!

Step 3

Start Capture, typically this should be called in your onResume so that the view maintains state with the implementing Activity/Fragment
1
@Override
2
protected void onResume() {
3
super.onResume();
4
try {
5
mSmartCardView.startCapture(mCurrentTag);
6
} catch (SIDException e) {
7
e.printStackTrace();
8
}
9
}
Copied!
The start capture method will display the view which should look like below
The method has a couple of possible errors that should be catered for this is important to make sure users get the best user experience and for handling possible failures gracefully.
    1
    //When camera initialisation fails
    2
    SIDError.COULD_NOT_INITIALIZE_CAMERA
    3
    4
    //when no listener is set
    5
    SIDError.MISSING_LISTENER
    6
    7
    //When an empty or invalid tag is set
    8
    SIDError.INVALID_TAG_FORMAT
    9
    10
    //If your app does not have camera permissions
    11
    SIDError.PERMISSION_ERROR
    12
    13
    //If the camera fails to process the captured image
    14
    SIDError.ID_CARD_PICTURE_CALLBACK_FAILED
    Copied!

Step 4

Implement pausing on the capture to handle view lifecycles
1
@Override
2
protected void onPause() {
3
super.onPause();
4
mSmartCardView.pauseCapture();
5
}
Copied!

Step 5

Error handling and callbacks from the ID Capture
1
@Override
2
public void onSmartCardViewError(Exception error) {
3
//todo:handle this
4
}
5
6
@Override
7
public void onSmartCardViewComplete(Bitmap idCardBitmap, boolean faceFound) {
8
//idCardBitmap the captured id card image
9
//faceFound true if a face was found on the ID
10
}
11
12
@Override
13
public void onSmartCardViewClosed() {
14
//User pressed X and the ID Card has been closed
15
}
Copied!

ID Capture Custom Messaging

To enable customization and internationalization from version 7.1.0 the ID Capture allows messaging customization through out the whole capture process as demonstrated in step 1
Last modified 4mo ago