【发布时间】:2020-01-30 06:40:32
【问题描述】:
我使用VNDocumentCameraViewController 扫描文档,使用VNRecognizeTextRequest 检测文本。它仅在以纵向模式扫描文档时有效。它的横向模式失败了。我可以在VNImageRequestHandler 中传递方向,但纵向扫描会失败。
同样,如果我尝试检查扫描图像的方向,它总是.up。所以我什至无法操纵图像。有人知道如何解决这个方向问题吗?我正在使用下面的代码。
@IBAction func scanTapped(_ sender: UIButton) {
allComponents = [Component]()
let documentCameraViewController = VNDocumentCameraViewController()
documentCameraViewController.delegate = self
self.present(documentCameraViewController, animated: true, completion: nil)
}
func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFinishWith scan: VNDocumentCameraScan) {
let image = scan.imageOfPage(at: scan.pageCount-1)
let handler = VNImageRequestHandler(cgImage: image.cgImage!, options: [:])
do {
try handler.perform([textRecognitionRequest])
} catch {
print(error)
}
controller.dismiss(animated: true)
}
【问题讨论】:
标签: swift ios13 ios-vision vndocumentcameraviewcontroller