【问题标题】:VNRecognizeTextRequest unable to recognise text scanned in landscape modeVNRecognizeTextRequest 无法识别以横向模式扫描的文本
【发布时间】: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


    【解决方案1】:

    我遇到了同样的问题。当我启用横向设备方向时,它就解决了。

    【讨论】:

      猜你喜欢
      • 2021-11-19
      • 2020-02-19
      • 1970-01-01
      • 2023-03-21
      • 2010-11-23
      • 2010-09-14
      • 1970-01-01
      • 1970-01-01
      • 2011-09-30
      相关资源
      最近更新 更多