import UIKit
import VisionKit
@available(iOS 13.0, *)
@objc public class ShgScanCardImage: UIViewController ,VNDocumentCameraViewControllerDelegate{
@objc public func scan() {
if !VNDocumentCameraViewController.isSupported {
return
}
let docVC = VNDocumentCameraViewController.init()
docVC.delegate = self
self.present(docVC, animated: true, completion: nil)
}
public func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFinishWith scan: VNDocumentCameraScan) {
controller.dismiss(animated: true, completion: nil)
let image = scan.imageOfPage(at: 0)
print(image)
}
public func documentCameraViewControllerDidCancel(_ controller: VNDocumentCameraViewController) {
controller.dismiss(animated: true, completion: nil)
}
public func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFailWithError error: Error) {
controller.dismiss(animated: true, completion: nil)
}
}
WechatIMG133.jpeg
网友评论