Sha256: 9e71738b289039f8d65b19dd185e6f00025c7ad2ea3a8ccc5088c9890b94e0b3

Contents?: true

Size: 670 Bytes

Versions: 4

Compression:

Stored size: 670 Bytes

Contents

# encoding: UTF-8
class RTesseract
  # Class to read char positions from an image
  class BoxChar < Box
    def config_hook
      @options['tessedit_create_boxfile'] = 1 # Split chars
    end

    alias_method :characters, :words

    def file_ext
      '.box'
    end

    def parse_file
      File.read(text_file_with_ext).to_s
    end

    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rtesseract-2.0.0 lib/rtesseract/box_char.rb
rtesseract-1.3.3 lib/rtesseract/box_char.rb
rtesseract-1.3.2 lib/rtesseract/box_char.rb
rtesseract-1.3.1 lib/rtesseract/box_char.rb