首页 > 解决方案 > Tesseract Worker.Load 挂在 Vercel 上

问题描述

不确定是否有人可以提供帮助,但我在我的 Next JS 应用程序中使用 Tesseract.js 在我的本地站点上有一个 OCR 阅读器。它在本地和读取 smy 图像上工作正常,但是当我部署到 Vercel 时它挂在这条线上......

await worker.load()

这是整个事情

  const worker = createWorker()
  console.log('createWorker')

  //attempt ocr on processed image
  await worker.load()
  console.log('worker.load')

  //set language to plain english
  await worker.loadLanguage('eng')
  await worker.initialize('eng')

  //set character whitelist and disable dictionary functions that won't help us here
  await worker.setParameters({
    tessedit_char_whitelist:
      '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-/$.@| ',
    load_system_dawg: 0,
    load_freq_dawg: 0,
  })
  console.log('setParameters')

  //process editted image
  const OcrResult = await worker.recognize(imageb64)
  if (process.env.DEBUG >= 1) {
    console.log('[DEBUG] OCR: Process complete, results: ', OcrResult.data.text)
  }

关于 Vercel 的任何怪癖会使它无法在测试站点上运行吗?

谢谢

标签: next.jstesseractvercel

解决方案


您可以尝试使用类似这样的东西,旨在用于 lambda 函数。

https://github.com/shelfio/aws-lambda-tesseract


推荐阅读