我最开始写了一个简单的脚本来读取图片数据。这里是我的Ruby代码,它使用RTesseract来读取:
require 'rtesseract'
require 'mini_magick'
RTesseract.configure do |config|
config.processor = "mini_magick"
end
image = RTesseract.new("myImage.jpg")
puts image.to_s
我使用了这张图片作为起点:
![enter image description here](https://istack.dev59.com/4BObJ.webp)
132B 4
。我知道0会返回成B(我可以解决)。但是接下来的
3
、0
和8
却没有返回。现在我知道它已经知道如何读取3和0了,因为它在第一个数字中已经读出来了。我想它可能在渲染后面的数字时遇到了一些问题,所以我将其变成了黑白色。这是我尝试的第二张图片:
![enter image description here](https://istack.dev59.com/UaoLa.webp)
132B 4
。最后,我剪切了图片并只尝试了最后3个数字。
这是图片:
![enter image description here](https://istack.dev59.com/61Qdx.webp)
我正在使用Ruby 2.2.2、rTesseract 2.1.0和MiniMagick 4.5.1。
我正在使用Tesseract 3.04.01。