Examples
Here are a few example of options you could have some interest in.
Camera orientation
The device orientation might be a little tricky to manage. If your app (Or the scanning screen) supports multiple interface orientation it's advised to re-instantiate the scanner in the transition delegate
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
coordinator.animate(alongsideTransition: { (v) in
//Remove smartscanner and nil it
}) { (v) in
//Add it again
}
}
Camera focus
You might to change the region of focus of the camera using continuousFocus
. For example :
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
if let coordinatesInPreviewView = touches.first?.location(in: self.preview) {
scanner?.continuousFocus(at: coordinatesInPreviewView)
}
}
Video Stream modifications
In some circonstance it might be interesting to do a few changes on the stream configuration.
//Changeing the zoom factor
scanner?.setNewZoomFactor(CGFloat( newZoomValue ))
//Some device supports a better framerate
scanner?.setCameraFramerate(60)
Simulator support
Indeed the camera is not supported in the simulator. But you can still simulate a SmartScanResult
using the smartScanShouldReturnResultCode
function.
Decoding behavior fine tuning
There is two parameters that might allow you to adjust how/when SmartScan will return you the results.
setSmartScannerResultBehavior
Will allow you to always return found values, to only return when the result has changed or stop trying to scan if a result is foundenableMultipleResultsConfirmation
Can be useful, mainly on contents that don't have any checksum, to ensure the result is more accurate (Mainly car license plates). Setting it to 4 , for example, will ensure that the code has been confirmed and read 4 times before validating it and returning it. Of course it make it a little slower.