Setup Accura MICR
To initialize sdk on app start:
import AccuraOCR
var accuraMICRWrapper: AccuraMICRWrapper? = nil
accuraMICRWrapper = AccuraMICRWrapper.init()
let sdkModel = accuraMICRWrapper.loadEngine(your PathForDirectories)
if (sdkModel.i > 0) {
if(sdkModel?.isMICREnable) {
}
}
Update filters config like below.
Call this function after initialize sdk if license is valid(sdkModel.i > 0)
Set Blur Percentage to allow blur on document
// 0 for clean document and 100 for Blurry document
self.accuraMICRWrapper?.setBlurPercentage(60/*blurPercentage*/)
Set Glare Percentage to detect Glare on document
// Set min and max percentage for glare
accuraMICRWrapper?.setGlarePercentage(6/*minPercentage*/, 98/*maxPercentage*/)
Set CameraView
Important Grant Camera and storage Permission. supports Landscape Camera
import AccuraOCR
import AVFoundation
var accuraMICRWrapper: AccuraMICRWrapper? = nil
override func viewDidLoad() {
super.viewDidLoad()
// initialize Camera for MICR
accuraMICRWrapper = AccuraMICRWrapper.init(delegate: self, andImageView: /*setImageView*/ _imageView, andLabelMsg: */setLable*/ lblOCRMsg, andurl: */your PathForDirectories*/ NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String, type: bankCode/*MICRTYPE*/)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
accuraMICRWrapper?.startCamera()
}
override func viewWillDisappear(_ animated: Bool) {
accuraMICRWrapper?.stopCamera()
accuraMICRWrapper = nil
super.viewWillDisappear(animated)
}
extension ViewController: VideoCameraWrapperDelegate{
//it sets ViewLayer border according to card image
func onUpdateLayout(_ frameSize: CGSize, borderRatio: Float) {
frameSize:- get layer frame size
borderRatio:- get layer ratio
}
// it calls continues when detect frame from camera
func processedImage(_ image: UIImage!) {
image:- get camara image.
}
// it call when license key wrong or didnt get key.license file
func recognizeFailed(_ message: String!) {
message:- message is a set alert message.
}
//it calls when get MICR data
func recognizeSucceedMICR(_ scanedInfo: String!, photoImage: UIImage!) {
}
// it calls when recieve error message
func reco_msg(_ message: String!) {
var msg = String();
if(message == ACCURA_ERROR_CODE_MOTION) {
msg = "Keep Document Steady";
} else if(message == ACCURA_ERROR_CODE_DOCUMENT_IN_FRAME) {
msg = "Keep document in frame";
} else if(message == ACCURA_ERROR_CODE_PROCESSING) {
msg = "Processing...";
} else if(message == ACCURA_ERROR_CODE_MOVE_CLOSER) {
msg = "Move Phone Closer"
}else if(message == ACCURA_ERROR_CODE_MOVE_AWAY) {
msg = "Move Phone Away"
}else if(message == ACCURA_ERROR_CODE_KEEP_MICR_IN_FRAME) {
msg = "Please Keep MICR in Frame"
}else {
msg = message;
}
print(message)
}
}
Last updated