【问题标题】:How to Resolve; tesseract: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory?如何解决; tesseract:加载共享库时出错:libpng12.so.0:无法打开共享对象文件:没有这样的文件或目录?
【发布时间】:2020-04-12 04:01:20
【问题描述】:

当我在使用 Heroku 18 Stack 的 Rails 应用程序中使用 tesseract build pack 处理带有 RTesseract gem 的图像时:

path = File.expand_path('app/assets/images/chicken_adobo_recipe.jpg')
# => "/app/app/assets/images/chicken_adobo_recipe.jpg"
image = RTesseract.new(path)
# => #<RTesseract:0x000055e949fc9120 @source="/app/app/assets/images/chicken_adobo_recipe.jpg", @config=#<RTesseract::Configuration command="tesseract", debug_file="/dev/null">, @errors=[]>
text = image.to_s

我的应用遇到以下错误:

Traceback (most recent call last):
        1: from (irb):4
RTesseract::Error (tesseract: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory)

为了确保它不仅仅是一个 RTesseract gem 问题,我运行了以下命令,但使用 tesseract 时我或多或少地遇到了相同的错误:

heroku run tesseract app/assets/images/chicken_adobo_recipe.jpg public/output

我的问题是:为什么我会遇到这个错误?错误是什么意思?还有,我该如何解决这个错误,以便我可以使用 tesseract 来解析图像中的文本?

这是我的 Aptfile:

tesseract-ocr
tesseract-ocr-eng

这是我的 Gemfile:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.5'

gem 'rails', '~> 6.0.1'
gem 'puma', '~> 4.1'
gem 'sass-rails', '>= 6'
gem 'webpacker', '~> 4.0'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.7'
gem 'bootsnap', '>= 1.4.2', require: false
gem 'haml', '~> 5.0', '>= 5.0.4'
gem 'pg', '1.2.3'
gem 'rtesseract', '3.1'
gem "wkhtmltoimage-binary", "0.12.4"

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'awesome_print'
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

【问题讨论】:

    标签: ruby heroku tesseract


    【解决方案1】:

    好的,我想通了。为了解决这个问题并继续使用 heroku 18 堆栈,我必须选择一个 heroku build pack,它安装了 Tesseract 的更新版本——4.0。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-19
      • 1970-01-01
      • 2016-05-22
      • 2014-04-08
      • 2012-01-20
      • 2019-04-23
      • 2021-05-26
      • 2020-11-18
      相关资源
      最近更新 更多