ocr_worker.rb 458 B

12345678910111213141516
  1. class OcrWorker
  2. include Sidekiq::Worker
  3. sidekiq_options :retry => false, :backtrace => true
  4. def perform(image_url)
  5. image_text = Curl.post("http://#{ENV['API_HOST']}:8008/ocr", {:img_url => image_url})
  6. if image_text and image_text.body
  7. entities = Curl.post("http://#{ENV['API_HOST']}:5000/api", {:text => image_text.body, :worker => "tesseract"})
  8. if entities
  9. return entities.body
  10. end
  11. end
  12. end
  13. end