Skip to main content

Initialization Parameters

Parameters passed when launching the OCR Lite SDK. The identity number is required; all other parameters are optional and have sensible defaults.

Parameters​

ParameterAndroid (OcrCommunication.ParamKey)iOS (OcrViewController)TypeRequiredDefault
Identity numberIDENTITY_NUMBERcnicNumberStringYes—
Image widthIMAGE_WIDTHimageWidthIntNo1000
Scan modeSCAN_MODEscanModeStringNo"frontAndBack"
Blur thresholdBLUR_THRESHOLDblurThresholdDouble (Android) / Float (iOS)No100
Motion thresholdMOTION_THRESHOLD—DoubleNo0.5
Show brandingSHOW_BRANDINGshowBrandingBooleanNofalse
FontFONT—Resource IDNoSDK default
Primary colorPRIMARY_COLOR—String (hex)NoSDK default
Skip processing—skipProcessingBooleanNofalse

Parameter Descriptions​

ParameterDescription
Identity numberThe CNIC number already known to your app. The SDK reads the number from the back-card barcode and compares it against this value (see distance). Android: a missing value causes a LAUNCH_FAILURE event. iOS: the value defaults to an empty string and no error is raised, so the comparison never matches.
Image widthTarget width in pixels for captured card images. Both front and back images are saved at this width; the height keeps the card's aspect ratio. Higher values preserve more detail but use more storage; lower values reduce file size.
Scan modeWhich sides of the card the user is asked to capture. One of "frontAndBack" (capture front, then back), "frontOnly" (capture front only), or "backOnly" (capture back only). An unknown value falls back to "frontAndBack". The scan mode changes which events are posted and which result fields are present — see Scan mode and results. On Android, the accepted values are also available as OcrCommunication.ScanMode.*.value.
Blur thresholdMinimum sharpness score a frame needs to be accepted. A frame whose score falls below this value is rejected as blurred, so higher values are stricter and lower values are more lenient. Recommended range: 50–400. Android: pass a Double (e.g. 100.0); an Int or Float extra is ignored and the default is used.
Motion thresholdAndroid only. Maximum camera movement allowed across recent frames, from 0.0 (still) to 1.0. A frame with more movement than this value is rejected as shaky, so lower values are stricter. Pass a Double.
Show brandingShows the provider logo on the scan screen when true.
FontAndroid only. Resource identifier (R.font.*) for the heading, subtitle and helper text shown in the OCR interface. Omit to use the SDK default typography.
Primary colorAndroid only. Hex color string (e.g. "#007083") used as the accent color (loading indicator) in the OCR interface. Omit to use the SDK default theme.
Skip processingiOS only. When true, the SDK skips classification and OCR on the first capture and immediately calls handleResponse with the cnicNumber you passed, empty images, documentType .old, distance 0 and an empty extractedData. Use it only to test your integration without a physical card.

Screen Orientation​

The SDK ships a portrait and a landscape scan screen. Both take the same parameters and post the same events.

OrientationAndroid activityiOS controller
Portraitcom.fetchsky.ocrlitesdk.OcrActivityOcrViewController
Landscapecom.fetchsky.ocrlitesdk.OcrLandscapeActivityOcrLandscapeViewController

The landscape screen runs full screen: the camera fills the display and the area outside the card holder is dimmed. Only the card holder region is classified and saved. For launch steps, see Android: Launch Landscape UI and iOS: Launch Landscape UI.

iOS landscape

Present OcrLandscapeViewController modally — do not embed it as a child view controller. It locks the interface to landscape, which works only for a presented controller. Your app must list landscape orientations in its supported interface orientations.

Android​

Pass parameters as Intent extras when launching OcrActivity (or OcrLandscapeActivity):

val intent = Intent(this, com.fetchsky.ocrlitesdk.OcrActivity::class.java)
intent.putExtra(OcrCommunication.ParamKey.IDENTITY_NUMBER.value, cnicNumber)
intent.putExtra(OcrCommunication.ParamKey.IMAGE_WIDTH.value, 1000)
intent.putExtra(OcrCommunication.ParamKey.SCAN_MODE.value, OcrCommunication.ScanMode.FRONT_AND_BACK.value) // Optional: "frontAndBack", "frontOnly", "backOnly"
intent.putExtra(OcrCommunication.ParamKey.BLUR_THRESHOLD.value, 100.0) // Optional, must be a Double
intent.putExtra(OcrCommunication.ParamKey.MOTION_THRESHOLD.value, 0.5) // Optional, must be a Double
intent.putExtra(OcrCommunication.ParamKey.SHOW_BRANDING.value, true) // Optional
intent.putExtra(OcrCommunication.ParamKey.FONT.value, R.font.poppins) // Optional
intent.putExtra(OcrCommunication.ParamKey.PRIMARY_COLOR.value, "#007083") // Optional
startActivity(intent)

iOS​

Pass parameters to the OcrViewController (or OcrLandscapeViewController) initializer:

let ocrController = OcrViewController(
cnicNumber: "your_cnic_number",
skipProcessing: false,
blurThreshold: 100,
imageWidth: 1000,
showBranding: false,
scanMode: "frontAndBack" // "frontAndBack", "frontOnly", "backOnly"
)