簡體   English   中英

VNRecognizeTextRequest 無法識別橫向模式下掃描的文本

[英]VNRecognizeTextRequest unable to recognise text scanned in landscape mode

我使用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)
}

我有同樣的問題。 當我啟用橫向設備方向時,它就解決了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM