Ios 如何处理拍摄的图像,然后将结果查看到;“文本视图”;使用Swift?

Ios 如何处理拍摄的图像,然后将结果查看到;“文本视图”;使用Swift?,ios,swift,uiimage,tesseract,Ios,Swift,Uiimage,Tesseract,我正在尝试用一个按钮构建一个简单的应用程序。单击按钮拍照,然后使用“TesseractOCR”将图像中的书面文本转换为字符串文本,并在“文本视图”中查看 我完成了一切,相机和“TesseractOCR”,我唯一面临的问题是: tesseract.image = UIImage(named: selectedImage) 给我这个错误: 无法将“UIImage”类型的值转换为预期的参数类型“String” 注意:选择“图像假定为Tesseract将图像转换为文本所用图像的名称” 这是我的密码:

我正在尝试用一个按钮构建一个简单的应用程序。单击按钮拍照,然后使用
“TesseractOCR”
将图像中的书面文本转换为字符串文本,并在“文本视图”中查看

我完成了一切,相机和“TesseractOCR”,我唯一面临的问题是:

 tesseract.image = UIImage(named: selectedImage)
给我这个错误:

无法将“UIImage”类型的值转换为预期的参数类型“String”

注意:选择“图像假定为Tesseract将图像转换为文本所用图像的名称”

这是我的密码:

import UIKit
import TesseractOCR

class secondViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, G8TesseractDelegate  {

    @IBOutlet weak var viewText: UITextView!

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    @IBAction func takePhoto(_ sender: Any) {
        if UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.camera) {
            let imagePicker = UIImagePickerController()
            imagePicker.delegate = self
            imagePicker.sourceType = UIImagePickerController.SourceType.camera
            imagePicker.allowsEditing = false
            self.present(imagePicker, animated: true, completion: nil)
        }
    }


    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {

        // The info dictionary may contain multiple representations of the image. You want to use the original.
        guard let selectedImage = info[.originalImage] as? UIImage else {
            fatalError("Expected a dictionary containing an image, but was provided the following: \(info)")
        }

        // Set photoImageView to display the selected image.
        if let tesseract = G8Tesseract(language: "eng") {
            tesseract.delegate = self
            tesseract.image = UIImage(named: selectedImage)
            tesseract.recognize()

            textView.text = tesseract.recognizedText

        }

        // Dismiss the picker.
        dismiss(animated: true, completion: nil)
    }

}
替换

tesseract.image = UIImage(named: selectedImage)

UIImage(名为:)
接受一个字符串值,该字符串值抑制捆绑包中的图像名称,但这里您不需要它,而是直接提供图像

tesseract.image = selectedImage