Accura OCR
High Accuracy OCR (Optical Character Recognition) Includes English, Latin, Chinese, Korean and Japanese Languages.
Step 1: Before you begin
If you haven't done already then follow Project Setup steps.
Please download the Accura Scan license and then add it to your app.
To generate your Accura Scan license contact [email protected]
Move your key.license file into the module (app-level) assets folder (usually
<project>/<app-module>/src/main/assets)
Note: Make sure license file name should be key.license
Permissions required
Camera Permission
android.permission.CAMERAStorage Permission required only for print out debug logs.
Step 2: Initialize SDK when the app starts
Initialize SDK with Licensing
RecogEngine recogEngine = new RecogEngine(); RecogEngine.SDKModel sdkModel = recogEngine.initEngine(your activity context); // Error Message if license is not valid. String licenseErrorMessage = sdkModel.message; if (sdkModel.i > 0) { // if license is valid if (sdkModel.isMRZEnable) // RecogType.MRZ if (sdkModel.isBankCardEnable) // RecogType.BANKCARD if (sdkModel.isAllBarcodeEnable) // RecogType.BARCODE // sdkModel.isOCREnable is true then get card list which you are selected on creating license if (sdkModel.isOCREnable) List<ContryModel> modelList = recogEngine.getCardList(MainActivity.this); if (modelList != null) { // if country & card added in license ContryModel contryModel = modelList.get(selected country position); contryModel.getCountry_id(); // getting country id CardModel model = contryModel.getCards().get(0/*selected card position*/); // getting card model.getCard_id() // getting card id model.getCard_name() // getting card name if (cardModel.getCard_type() == 1) { // RecogType.PDF417 } else if (cardModel.getCard_type() == 2) { // RecogType.DL_PLATE } else { // RecogType.OCR } } }// Error Message if license is not valid. String licenseErrorMessage = sdkModel.message;After initializing the SDK, proceed to initialize the filters below if the license is valid.
(sdkModel.i > 0)
Set Blur Percentage to allow blur on document
//0 for clean document and 100 for Blurry document recogEngine.setBlurPercentage(Context context, int /*blurPercentage*/50);
Set Face blur Percentage to allow blur on detected Face
// 0 for clean face and 100 for Blurry face recogEngine.setFaceBlurPercentage(Context context, int /*faceBlurPercentage*/50);
Set Glare Percentage to detect Glare on document
// Set min and max percentage for glare recogEngine.setGlarePercentage(Context context, int /*minPercentage*/6, int /*maxPercentage*/98);
Set Hologram detection to verify the hologram on the face
// true to check hologram on face recogEngine.SetHologramDetection(Context context, boolean /*isDetectHologram*/true);
Set light tolerance to detect light on document
// 0 for full dark document and 100 for full bright document recogEngine.setLowLightTolerance(Context context, int /*tolerance*/30);
Set motion threshold to detect motion on camera document
// 1 - allows 1% motion on document and // 100 - it can not detect motion and allow document to scan. recogEngine.setMotionThreshold(Context context, int /*motionThreshold*/18);
Step 3 : Set CameraView
Your activity class should extend
com.accurascan.ocr.mrz.motiondetection.SensorsActivity.Camera View support both orientations Portarait and Landscape
Note: Make sure your activity orientation should be finalise before Initialize camera because auto rotate is not support during scanning.
Initialize cameraView to your activity class.
And recommended to override the following methods.
Implements
com.accurascan.ocr.mrz.interfaces.OcrCallbackto your Activity and Override following methods to receive data during scanning.Note: Below Override methods are invoked from background thread. So make sure to use in UI thread
When below override method is getting called, you can start scanning and set parameter of center scanning frame.
You can receive information during scanning in the below override method
Note : (Optional)
cameraView.flipImage(imageFlip);Use to display default flip card animation. You can use your custom animation for flip card.You can receive and display the scanned result in the below override method. The method below is invoked twice for RecogType.PDF417 and RecogType.OCR. And for the RecogType.OCR, it can be invoked once or twice with respect to a document. You can verify this with
cameraView.isBackSideAvailable(). It will return true if the back is available, otherwise return false.
Note: It is necessary to release the camera view before showing the result on the results screen. Before releasing it, ensure that both sides of the document must be scanned as per your requirements. If you only scan one side and then release it directly, it may not fulfill your requirements.
Receive error messages
(Optional)To restart the scanning process after obtaining the result, you need to include the following code. This code should be placed within the override method of an Android activity, which gets called when you open the result activity using the
startActivityForResult(Intent, RESULT_ACTIVITY_CODE).
Last updated