Class: RTesseract::BoxChar
- Inherits:
-
Box
- Object
- RTesseract
- Box
- RTesseract::BoxChar
- Defined in:
- lib/rtesseract/box_char.rb
Overview
Class to read char positions from an image
Constant Summary
Constants inherited from RTesseract
Instance Attribute Summary
Attributes inherited from RTesseract
#image_object, #lang, #options, #options_cmd, #processor, #psm, #source
Instance Method Summary collapse
Methods inherited from Box
#after_convert_hook, #initialize_hook, #to_s, #words
Methods inherited from RTesseract
#after_convert_hook, choose_processor!, #clear_console_output, #command_line_options, #config, #config_file, #convert, #convert_command, #crop!, #default_command, #from_blob, #image, #initialize, #initialize_hook, #read, read, #remove_file, #text_file, #text_file_with_ext, #to_s, #to_s_without_spaces
Constructor Details
This class inherits a constructor from RTesseract
Instance Method Details
#config_hook ⇒ Object
5 6 7 |
# File 'lib/rtesseract/box_char.rb', line 5 def config_hook @options['tessedit_create_boxfile'] = 1 # Split chars end |
#convert_text ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/rtesseract/box_char.rb', line 19 def convert_text text_objects = [] parse_file.each_line do |line| char, x_start, y_start, x_end, y_end, _word = line.split(' ') text_objects << { char: char, x_start: x_start.to_i, y_start: y_start.to_i, x_end: x_end.to_i, y_end: y_end.to_i } end @value = text_objects end |
#file_ext ⇒ Object
11 12 13 |
# File 'lib/rtesseract/box_char.rb', line 11 def file_ext '.box' end |
#parse_file ⇒ Object
15 16 17 |
# File 'lib/rtesseract/box_char.rb', line 15 def parse_file File.read(text_file_with_ext).to_s end |