为Heroku Rails应用程序实现OCR

时间:2013-11-17 17:57:04

标签: ruby-on-rails heroku ocr tesseract

我需要在Heroku上使用Rails应用程序的OCR功能。我努力让tesseract工作并没有成功。有没有人有什么建议?很难相信像OCR这样基本的东西并不像Heroku上的Rails那样普遍存在。

努力工作的背景

特定错误加载TESSERACT_BIN宝石

/Users/palfvin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/pathname.rb:422:in `open': No such file or directory - /Users/palfvin/.rvm/gems/ruby-2.0.0-p247@avlats/gems/tesseract_bin-1.0.2/bin (Errno::ENOENT)
    from /Users/palfvin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/pathname.rb:422:in `foreach'
    from /Users/palfvin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/pathname.rb:422:in `children'
    from /Users/palfvin/.rvm/gems/ruby-2.0.0-p247@avlats/gems/tesseract_bin-1.0.2/lib/tesseract_bin.rb:7:in `<module:TesseractBin>'
    from /Users/palfvin/.rvm/gems/ruby-2.0.0-p247@avlats/gems/tesseract_bin-1.0.2/lib/tesseract_bin.rb:3:in `<top (required)>'
    from /Users/palfvin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require'
    from /Users/palfvin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
    from /Users/palfvin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
    from tmp/tesseract.rb:261:in `<main>'

1 个答案:

答案 0 :(得分:4)

我在RoR中为Heroku开发了一个使用Tesseract OCR的简单服务器。服务器接收jpg图像,运行OCR并将文本作为字符串返回。这对你来说可能是一个很好的起点。

  

https://github.com/fouady/RoR-Tesseract-Heroku

另外,我使用了自己修改过的自定义buildpack。你会在这里找到详细信息:

  

https://github.com/fouady/heroku-buildpack-tesseract

我希望这能解决你的问题。