DSHandler
@objc
open class DSHandler : NSObject
A handler that scans and tries to detect the specified type of document
Discussion: A handler that scans for configured types of documents. For example when a option of passport is given to the handler it will try to scan for passports using some detection methods tailored to passports. This doesn’t mean it won’t detect objects that are passport like, but the algorithums are optimized for the given configuration.
Example Usage:
class SomeController: UIViewController {
...
private let documentScanHandler: DSHandler!
func viewDidLoad() {
super.viewDidLoad()
documentScanHandler = DSHandler(delegate: self)
}
func doScan() {
let options = DSID1Options()
options.side = .Back
options.detectFace = false
documentScanHandler?.options = options
self.present(documentScanHandler.scanController, animated: true)
documentScanHandler?.start()
}
...
}
extension: DSHandlerDelegate {
func handleScan(result: DSResult) {
//do something with result
}
}
-
The reciever’s delegate
Declaration
Swift
@objc weak public private(set) var delegate: DSHandlerDelegate? { get }
-
Provides a new instance of the scan controller.
Discussion Each call to this property will return a new UIViewController to the caller, if you wish to cache properties on this controller the caller should maintain the lifecycle for the controller
Declaration
Swift
@objc open var scanController: ScanViewController { get }
-
The options you want to use for a given scan. For example an option of DSID1Options scans for ID style documents. Defaults to DSID1Options
Declaration
Swift
@objc public var options: DSOptions { get set }
-
Creates an instance of the DSHandler.
Declaration
Swift
@objc public convenience init(delegate: DSHandlerDelegate, captureMode: DSCaptureMode = .Manual)
Parameters
delegate
The reciever’s delegate that will be called when events occur during and after the scan
captureMode
The mode you want to use for capture. Defaults to Manual
-
Creates an instance of the DSHandler.
Declaration
Swift
@available(*, deprecated, message: "Please use the scanController property, take the scanController add or present the scanController from your UIViewController") @objc public init(controller: UIViewController?, delegate: DSHandlerDelegate, captureMode: DSCaptureMode = .Manual)
Parameters
controller
The UIViewController that will be used to present the scan docuemnt screen
delegate
The reciever’s delegate that will be called when events occur during and after the scan
captureMode
The mode you want to use for capture. Defaults to Manual
-
Starts a scan with the given options for the handler
Declaration
Swift
@objc public func start()
-
Stops a scan if a scan is in progress
Declaration
Swift
@objc public func stop()
-
Tells the handler to capture the current frame in view.
Overview This fuction is primary usage is with a Manual capture. Calling this method will tell the handler to capture the current frame and return the resutls to the delegate.
When using the handler with a UIViewController the invokation of this method is done automatically when the user taps the capture action item.
Declaration
Swift
@objc public func doCapture()
-
Undocumented
See moreDeclaration
Swift
public enum ScanError : Error
-
Undocumented
Declaration
Swift
open func scan(image: UIImage, flashImage flash: UIImage? = nil) throws