Unfortunately it doesn't look like the API honours the environment variable or the assignment to Tesseract.prefix
irb> Tesseract.prefix = Rails.root.join("db","tessdata").to_s
irb> eng = Tesseract::Engine.new {|e| e.language = :eng }
Error opening data file /home/will/test-app/tessdata/eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!
RuntimeError: the API did not Init correctly
from /home/will/.rvm/gems/ruby-2.0.0-p247@hipyard-web/gems/tesseract-ocr-0.1.6/lib/tesseract/api.rb:104:in `init'
I've made a quick monkey patch that does the job but I'd imagine you want a more elegant solution for a PR - so I'll just post this hack for now:
module Tesseract
class API
def init (datapath = nil, language = 'eng', mode = :DEFAULT)
datapath = Tesseract.prefix
unless C::BaseAPI.init(to_ffi, datapath, language.to_s, mode).zero?
raise 'the API did not Init correctly'
end
end
end
end
Unfortunately it doesn't look like the API honours the environment variable or the assignment to Tesseract.prefix
I've made a quick monkey patch that does the job but I'd imagine you want a more elegant solution for a PR - so I'll just post this hack for now: