DocumentDetector v7.x or below
Supported documents
Currently, supported documents on Android are:
SDK size
The SDK size is approximately 3.3 MB, which may decrease due to these elements.
Runtime permissions
Permission | Reason | Required? |
---|---|---|
| To capture photos of the documents. | Only for capture feature. |
| To access the device external storage and select documents in the upload flow. | Only for upload feature. |
| To access the device media storage and select documents in the upload flow. | Only for upload feature. |
| To collect connection data with the signal tower, for analytical purposes only. | No. |
Instantiating the SDK
First things first, instantiate an object of type DocumentDetector
. This object will contain all your business rules for the SDK:
All parameters annotated with
@Nullable
can receivenull
values, useful if you want to configure only one of the parameters of the same method.
Builder method
Parameter | Required |
---|---|
Token associated with your account, to use the SDK. | Yes. |
| Yes. |
User identifier for fraud profile identification purposes and to assist in the identification of Analytics logs in cases of bugs and errors. | |
| No. The default value is true. |
| No. |
Enables/disables the popups displayed before each document capture. | No. The default value is true. |
| No. |
Set the mask design displayed during captures. There are three types:
| No. The default value is |
Allows full customization of the masks displayed during document capture. Three types are required, one for each document validation feedback during capture: SUCCESS (greenMask), NORMAL (whiteMask) e ERROR (redMask). Going with this option, use masks with the same detection area as the document, this is extremely important for the algorithm to perform validations during the capture. | No. See our mask templates to get the detection area: |
| No. |
Enables/Disables SDK audio playback. | No. The default value is |
Defines SDK's requests timeout. | No. The default value is 60 (seconds). |
Defines threshold between acceptable/unacceptable ambient brightness. Set | No. The default settings are 5 (lx). |
Defines threshold between correct/incorrect device orientation. Higher the value more flexible it will be. Set | No. The default setting is 3 (m/s²). |
Defines stability sensor settings. Set | No. The default setting is time 2000 (ms) and threshold 0.5 (m/s²). |
| No. The default setting is |
Enables/disables and allows the configuration of the visualization of the capture performed, requesting the user's confirmation to proceed. | No. The default is disabled. |
Enables/disables auto-detection and sensor checks. Use false to disable all checks on the device. This way, all validations will be performed on the backend after the capture. | No. The default is |
Delays the activity after the completion of each step. This method can be used to display a success message on the screen itself after the capture, for example. | No. The default is |
| No. |
Enables/disables the button for the user to switch between the front and rear cameras. | No. The default is |
Allows you to set the capture resolution. The method takes as a parameter a
| No. The default is |
Allows you to configure the quality in the compression process. By default, all captures go through compression. The method expects values between 50 and 100 as a parameter, where 100 is the best quality compression (recommended). | No. The default is |
Allows you to enable/disable features of the SDK that consume GoogleServices in the SDK, we do not recommend disabling the services because of the loss of security. | No. The default is |
Allows the use of emulators when | No. The default is |
Allows the use of root devices when | No. The default is |
Enables the use of developer mode when | No. The default is |
Enables Android Debug Bridge (ADB) debugging mode when | No. The default is |
Allows you to use the app in debug mode when | No. The default is |
Sets the time the image URL will last on the server until it is expired. Expect to receive a time interval between "30m" to "30d". Examples:
| No. The default is |
No. By default, this option is disabled. | |
Example:
| No. Passports issued by any country are accepted by default. |
Allows you to choose the environment in wich the SDK will run (production, beta). The method takes as parameter an enum | No. The default is |
Enum | Description |
| Will use the Trust Platform production environment to register the SDK executions. |
| Will use the Trust Platform beta environment to register the SDK executions. |
Each environment (beta and production) requires its own specific mobileToken, generated in the Trust platform of the respective environment.
DocumentDetectorStep
To create a capture flow, you will need to create an array of DocumentDetectorStep
, where each element will be a capture step. To construct each DocumentDetectorStep
object, you can enter the following elements:
Parameter | Required |
---|---|
| Yes. |
Defines text to be shown in the lower part of the layout. | No. There is a pattern by |
Defines illustration to be shown in the popup prior to capture. | No. There is a pattern by |
Sets audio that will be played at the beginning of the step. | No. There is a pattern by |
Sets the masks for each document type. Using this method overrides the masks defined in the | No. The default is set by the |
CaptureStage
To improve the client's UX, we recommend creating difficulty stages for the DocumentDetector. For this, we offer the CaptureStage object, where you can set the following parameters:
Parameter |
---|
Duration of the stage, in milliseconds. If you do not want a timeout, parameterize |
Enables/Disables the use of sensors for capturing the photo. |
Document quality check settings. If you do not want to check the quality of the document, set |
Settings for automatic document detection. If you do not want to use automatic detection, set |
Document capture mode, which can be |
Since the .setCaptureStages
parameter is not required, if it is not used, the DocumentDetector
will use this default:
QualitySettings
Parameter | Observarions |
---|---|
Threshold that defines whether the document capture has quality or not. | Ranges from 1.0 to 5.0, where 1.8 is the recommended threshold. |
DetectionSettings
Parameter | Observarions |
---|---|
Threshold that defines whether or not the document displayed by the user is the document being requested. | A value between 0.0 and 1.0, where 0.95 is recommended. |
Number of consecutive correct frames for document acceptance. | 5 is recommended. The more frames, the longer it will take to detect the document. |
UploadSettings
To enable the document upload functionality it is necessary to instantiate an object of type UploadSettings(boolean enable) and set its parameters:
Parameter | Required |
---|---|
Enables/disables this feature. | No. The default is true. |
Enables/disables file compression before uploading. | No. The default is |
Defines the file format(s) that will be accepted for upload. | No. By default .PDF, .JPG, .JPEG, .PNG, .HEIF are accepted. |
Sets the maximum KB limit of the file to upload. | No. The default limit is 10000 KB (10MB). |
Defines the background layout of the document upload. | No. |
Defines the layout of the document upload request popup. | No. |
Currently, the supported file formats are:
MessageSettings
To use, simply instantiate a MessageSettings
object and use the methods as needed for customization.
Method | Default value |
---|---|
Message displayed in the subtitle of the pop-up that brings the illustration of the document that is being requested for capture. | “Posicione o documento em uma mesa, centralize-o na marcação e aguarde a captura automática.” |
Message telling you to fit the document to the mask. | "Encaixe o documento na marcação" |
Message displayed at the moment the capture is being performed. | "Segure assim" |
Message displayed when the SDK makes a request to the backend, checking for quality. | "Verificando qualidade…" |
Message displayed when the capture quality fails. | "Ops, não foi possível ler as informações. Por favor, tente novamente" |
Message displayed when there is no quality check and the capture is being saved on the servers. | "Enviando imagem…" |
Message displayed when displaying an open document, the message will be displayed together with the error message on the document being used, example: if the user displays an open CNH(Brazilian drive’s license), the standard error message "Essa é uma CNH Aberta" + the defined message will be displayed. | "Use o documento fechado e tente novamente" |
Message displayed when you start the camera. | "Aguarde..." |
Message displayed when the brightness threshold is lower than expected. | "Ambiente muito escuro" |
Message displayed when the orientation threshold is lower than expected. | "Celular não está na vertical" |
Message displayed when the orientation threshold is lower than expected. | "Mantenha o celular parado" |
Message displayed when the front of the RG(Brazilian ID card) is displayed in a different flow than expected. | "Ops, esta é a frente do RG" |
Message displayed when the RG(Brazilian ID card) version is displayed in a different flow than expected. | "Ops, este é o verso do RG" |
Message displayed when the open RG(Brazilian ID card) is displayed in a different stream than expected. | "Ops, este é o RG aberto" |
Message displayed when the front of the CNH(Brazilian driver's license) is displayed in a different stream than expected. | "Ops, esta é a frente da CNH" |
Message displayed when the version of the CNH(Brazilian driver's license) is displayed in a different stream than expected. | "Ops, este é o verso da CNH" |
Message displayed when the open CNH(Brazilian driver's license) is displayed in a different stream than expected. | "Ops, esta é a CNH aberta" |
Message displayed when the CRLV(Brazilian Vehicle Registration and Licensing Certificate) is displayed in a different stream than expected. | "Ops, este é o CRLV" |
Message displayed when the front of the RNE(National Registry of Foreigners) is displayed in a different stream than expected. | "Ops, esta é a frente do RNE" |
Message displayed when the back of the RNE(National Registry of Foreigners) is displayed in a different stream than expected. | "Ops, este é o verso do RNE" |
Allows for customization of the confirmation button message. | Não. O padrão é "Ok, entendi!" |
Sets the title of the upload popup when the uploaded file exceeds the maximum allowed size. | Não. O padrão é "Tamanho do arquivo excedido" |
Sets the upload popup message when the uploaded file exceeds the maximum allowed size. | Não. O padrão é "Parece que o arquivo que você escolheu excede o tamanho permitido. Tente enviar um arquivo menor." |
Sets the title of the upload popup when the format of the uploaded file is not valid. | Não. O padrão é "Formato inválido." |
Sets the upload popup message when the format of the uploaded file is not valid. | Não. O padrão é "Parece que o formato do arquivo não é suportado. Tente reenviar usando os formatos de JPG, PNG ou PDF." |
Sets the generic error title for the upload popup. | Não. O padrão é "Ops, algo deu errado." |
Sets the generic error message for the upload popup. | Não. O padrão é "Parece que o documento não é o esperado. Envie um arquivo com o tipo de documento solicitado." |
Sets the title of the upload popup when the quality of the uploaded image fails. | Não. O padrão é "Ops, qualidade baixa" |
Sets the upload popup message when the quality of the uploaded image fails. | Não. O padrão é "Parece que a qualidade da imagem documento está muito baixa. Tente enviar um arquivo com melhor qualidade." |
Sets the message displayed in the upload popup while the file is being uploaded. | Não. O padrão é "Enviando documento" |
Example
Security validations
We are constantly taking actions to make the product more and more secure, mitigating a number of attacks observed in the capture process and, consequently, reducing as many possible identity frauds as possible. The SDK has some blocks that may prevent its execution in certain contexts. To disable them, you can use the methods as shown in the example below:
Disabling security validations is recommended for testing purposes only. For publishing your application in production, we recommend using the default settings.
Starting Activity
After creating the DocumentDetector
, start the DocumentDetectorActivity
by passing this object as a parameter via extra intent:
Getting the result
To get the DocumentDetectorResult
object, which contains the captures taken by the SDK, override the onActivityResult
method in the same Activity that you started the DocumentDetectorActivity
:
DocumentDetectorResult
Parameter | Allow null |
---|---|
The array with the respective captures of the parameterized documents. | Yes, in case of error |
The class of the read document stream. This parameter is useful in an integration with our OCR route. | Yes, in case of an error or when you couldn't check the quality. |
Identifier of this execution on our servers. If possible, save this field and send it along to our API. This way we will have more data on how the user behaved during the execution. | Yes, if the user sets |
| Yes, in case of success |
Capture
Parameter | Allow null |
---|---|
Full path of the image on the user's device. | No. |
URL of the document on the CAF server. | No. |
Identification of the type of the captured document, within the following possibilities: | Yes, when you could not check the quality. |
Quality is inferred by the document quality algorithm when enabled. Ranges from 1.0 to 5.0. | Yes, when you could not check the quality. |
Defines the face of the camera that was used. Use | No. |
Last updated