【问题标题】:React Native - Tesseract.js - Error: Cannot create URL for blobReact Native - Tesseract.js - 错误:无法为 blob 创建 URL
【发布时间】:2019-12-29 00:40:29
【问题描述】:

我在 React Native 应用程序(在 Android 平台上)中使用 Tesseract.js 库时遇到问题。我目前正在应用程序中拍照,将图像信息保存在base64 string 中并尝试将其传递给worker.recognize() 函数。传递给函数的字符串按如下方式构建:data:image/jpeg;base64,MY_BASE64_STRING。我还尝试将 URL 传递给图像,并尝试使用图像文件的绝对路径,但总是遇到同样的错误:

错误:无法为 blob 创建 URL!

这是我用于 2.0.0-alpha.13 版本的代码:

const { TesseractWorker } = Tesseract
const worker = new TesseractWorker({
    workerPath: '../../../node_modules/tesseract.js/dist/worker.min.js',
    langPath: '../../assets/lang',
    corePath: '../../../node_modules/tesseract.js-core/tesseract-core.wasm.js',
    })

worker
    .recognize(`data:image/jpeg;base64,${data.base64}`)
    .progress(info => {
        console.log(info)
    })
    .then(result => {
        console.log(result.text)
    })

我尝试使用版本 1.0.19 和 alpha 版本 2.0.0-alpha.13

谢谢大家! ♥

【问题讨论】:

    标签: javascript react-native tesseract.js


    【解决方案1】:

    根据这个问题,Tesseract.js 不支持 react-native。

    https://github.com/naptha/tesseract.js/issues/55

    使用这个使用原生移动模块的库。不过可能不适用于世博会

    https://github.com/jonathanpalma/react-native-tesseract-ocr

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-10
      相关资源
      最近更新 更多