【问题标题】:Javascript resize buffered image to improve tesseract OCR accuracyJavascript 调整缓冲图像的大小以提高 tesseract OCR 的准确性
【发布时间】:2019-05-03 11:02:27
【问题描述】:

如何在传递到 tesseract OCR 之前重新缩放缓冲图像以提高准确性?无论如何都不会实际绘制图像,因为它只是用于处理,所以不确定这是如何完成的。我正在制作一个电子应用程序,但不确定如何以这种方式放大图像。

因为它不是很准确,因为我需要处理的图像非常小。

const image = 'image.png';
tesser(image);

function tesser(image) {
  Tesseract.recognize(image)
  .then(function(result){
      console.log(result.text)
  })
}

【问题讨论】:

标签: javascript ocr tesseract


【解决方案1】:

由于没有人回答,我将在最后发布我发现的内容。我可以使用 lib Sharp 来调整缓冲图像的大小。

img.onload = resizeImg;
img.src = 'image.png';

function resizeImg() {
  this.path = this.path = 'image.png';

  sharp(this.path)
  .resize(this.width * 2, this.height * 2)
  .toBuffer({ resolveWithObject: true })
  .then(({ data, info }) => {
      //process data
  })
}

【讨论】:

    猜你喜欢
    • 2012-03-17
    • 2021-06-30
    • 2017-04-03
    • 2019-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多