Class: Despeck::Ocr

Inherits:
Object
  • Object
show all
Defined in:
lib/despeck/ocr.rb

Overview

Extracts text of desired language from the image

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image) ⇒ Ocr

Returns a new instance of Ocr.



8
9
10
# File 'lib/despeck/ocr.rb', line 8

def initialize(image)
  @image_path = image
end

Instance Attribute Details

#image_pathObject (readonly)

Returns the value of attribute image_path.



6
7
8
# File 'lib/despeck/ocr.rb', line 6

def image_path
  @image_path
end

#langObject (readonly)

Returns the value of attribute lang.



6
7
8
# File 'lib/despeck/ocr.rb', line 6

def lang
  @lang
end

Instance Method Details

#text(lang: :eng) ⇒ Object



12
13
14
# File 'lib/despeck/ocr.rb', line 12

def text(lang: :eng)
  RTesseract.new(image_path, lang: lang).to_s
end