首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VNRecognizeTextRequest无法识别在横向模式下扫描的文本

VNRecognizeTextRequest无法识别在横向模式下扫描的文本
EN

Stack Overflow用户
提问于 2020-01-30 14:40:33
回答 1查看 128关注 0票数 4

我使用VNDocumentCameraViewController扫描文档,使用VNRecognizeTextRequest检测文本。只有在纵向模式下扫描文档时,它才起作用。It横向模式它失败了。我可以通过VNImageRequestHandler中的定位,但这对于肖像扫描将失败。同样,如果我尝试检查扫描的图像方向,它总是.up。所以我甚至不能操纵图像。有谁知道如何解决这个定向问题?我正在使用下面的代码。

代码语言:javascript
复制
@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)
}
EN

回答 1

Stack Overflow用户

发布于 2021-01-17 00:59:35

我也有同样的问题。当我启用横向设备定向时,这个问题就解决了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59980388

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档