Class: RTesseract::Uzn
- Inherits:
-
RTesseract
- Object
- RTesseract
- RTesseract::Uzn
- Defined in:
- lib/rtesseract/uzn.rb
Overview
Alternative approach to Mixed when you want to read from specific areas. Requires ‘-psm 4` which means the text must be “a single column of text of variable sizes”.
Constant Summary collapse
- DEFAULT_ALPHABET =
'Text/Latin'
Constants inherited from RTesseract
Instance Attribute Summary collapse
-
#areas ⇒ Object
readonly
Returns the value of attribute areas.
Attributes inherited from RTesseract
#configuration, #processor, #source
Instance Method Summary collapse
- #after_convert_hook ⇒ Object
-
#area(points) ⇒ Object
Add areas.
- #convert_command ⇒ Object
-
#initialize(src = '', options = {}) {|_self| ... } ⇒ Uzn
constructor
A new instance of Uzn.
Methods inherited from RTesseract
#clean, #clear_console_output, clear_pdf_option, #config, #config_file, #config_hook, configure, #convert, #convert_pdf, #convert_result, #convert_text, #crop!, default_command, #file_dest, #file_ext, #file_with_ext, #from_blob, #image, #initialize_hook, #lang, local_config, #oem, #option_to_string, #options_cmd, #pdf?, #psm, #read, read, #tessdata_dir, #tesseract_version, #to_pdf, #to_s, #to_s_without_spaces, #user_patterns, #user_words
Constructor Details
#initialize(src = '', options = {}) {|_self| ... } ⇒ Uzn
Returns a new instance of Uzn.
10 11 12 13 14 15 |
# File 'lib/rtesseract/uzn.rb', line 10 def initialize(src = '', = {}) @areas = .delete(:areas) || [] @alphabet = .delete(:alphabet) || DEFAULT_ALPHABET super(src, .merge(psm: 4)) yield self if block_given? end |
Instance Attribute Details
#areas ⇒ Object (readonly)
Returns the value of attribute areas.
7 8 9 |
# File 'lib/rtesseract/uzn.rb', line 7 def areas @areas end |
Instance Method Details
#after_convert_hook ⇒ Object
28 29 30 |
# File 'lib/rtesseract/uzn.rb', line 28 def after_convert_hook RTesseract::Utils.remove_files([@uzn_file]) end |
#area(points) ⇒ Object
Add areas
18 19 20 |
# File 'lib/rtesseract/uzn.rb', line 18 def area(points) areas << points end |
#convert_command ⇒ Object
22 23 24 25 26 |
# File 'lib/rtesseract/uzn.rb', line 22 def convert_command @image = image write_uzn_file `#{configuration.command} "#{@image}" "#{file_dest}" #{lang} #{psm} #{tessdata_dir} #{user_words} #{user_patterns} #{config_file} #{clear_console_output} #{.join(' ')}` end |