Skip to main content
Version: 2.5.4

Base Implementation

Start to scan

//Instanciate the scanner
let scan = SmartScanner()
//Create a view and use it like a standard UIView
let preview = scan.previewView(withViewSize: self.view.bounds)
scan.scDelegate = self
self.view.insertSubview(preview!, at: 0)

//Set the type of code to decode
scan.setDecodingType(CODE_EU_PLATES.rawValue andSubType: CODE_PLT_CHE.rawValue)

//For some types of OCR the camera orientation should be specified
scan.setDecoding(UIApplication.shared.statusBarOrientation)

//Customize your ROI if needed, this need to be done after setting the type of code
let regionOfInterest = CGRect(x: 0.0, y: 0.0, width: 160, height: 160)
scan.setRegionOfInterest(regionOfInterest)

Select the type of code you want to decode

You can use a combination of any type or subtype that is enabled in the version you have. At any point you can set another decoding type (Verify the enabled types of your SmartScan version by calling the version function).

Thoses are referenced in the enums

In the header file IcareDecodersCodes.hpp
SmartDecodingSubTypes
SmartDecodingTypes

For example

//Use the rawValue of the enums
var typeOfCode : UInt64 = CODE_OCRB.rawValue
var subtypeOfCode : UInt64 = CODE_BVR.rawValue | CODE_ICAO_9303_IDCARD.rawValue

//Configuring what type of content to scan.
scan.setDecodingType(typeOfCode, andSubType: subtypeOfCode)

Retrieve the results by implementing the delegate protocol

func smartScan(_ smartScanner: SmartScanner, found smartScannerResult: SmartScanResult) {
print("Result : \(smartScannerResult.content) type : \(smartScannerResult.codeDescription)")
}

Release the resources when you don't need to use the smartscanner anymore

sc?.closeCameraStream()
sc = nil