Class: Tesseract::API::Iterator
- Inherits:
-
Object
- Object
- Tesseract::API::Iterator
- Defined in:
- lib/tesseract/api/iterator.rb
Class Method Summary collapse
-
.finalize(pointer) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #baseline(level = :word) ⇒ Object
- #begin ⇒ Object
- #beginning?(level = :word) ⇒ Boolean
- #block_type ⇒ Object
- #bounding_box(level = :word) ⇒ Object
- #confidence(level = :word) ⇒ Object
- #end?(level, element) ⇒ Boolean
- #get_binary_image(level = :word) ⇒ Object
- #get_image(level = :word, padding = 0) ⇒ Object
- #get_text(level = :word) ⇒ Object
-
#initialize(pointer) ⇒ Iterator
constructor
A new instance of Iterator.
- #next(level = :word) ⇒ Object
- #orientation ⇒ Object
- #symbol_is_dropcap? ⇒ Boolean
- #symbol_is_subscript? ⇒ Boolean
- #symbol_is_superscript? ⇒ Boolean
- #to_ffi ⇒ Object
- #word_font_attributes ⇒ Object
- #word_is_from_dictionary? ⇒ Boolean
- #word_is_numeric? ⇒ Boolean
Constructor Details
#initialize(pointer) ⇒ Iterator
Returns a new instance of Iterator.
28 29 30 31 32 |
# File 'lib/tesseract/api/iterator.rb', line 28 def initialize (pointer) raise ArgumentError, 'the pointer is null' if pointer.nil? || pointer.null? @internal = FFI::AutoPointer.new(pointer, self.class.method(:finalize)) end |
Class Method Details
Instance Method Details
#baseline(level = :word) ⇒ Object
68 69 70 |
# File 'lib/tesseract/api/iterator.rb', line 68 def baseline (level = :word) C::Iterator.baseline(to_ffi, C.for_enum(level)) end |
#begin ⇒ Object
38 39 40 |
# File 'lib/tesseract/api/iterator.rb', line 38 def begin C::Iterator.begin(to_ffi) end |
#beginning?(level = :word) ⇒ Boolean
42 43 44 |
# File 'lib/tesseract/api/iterator.rb', line 42 def beginning? (level = :word) C::Iterator.is_at_beginning_of(to_ffi, C.for_enum(level)) end |
#block_type ⇒ Object
90 91 92 |
# File 'lib/tesseract/api/iterator.rb', line 90 def block_type C::Iterator.block_type(to_ffi) end |
#bounding_box(level = :word) ⇒ Object
54 55 56 |
# File 'lib/tesseract/api/iterator.rb', line 54 def bounding_box (level = :word) C::Iterator.bounding_box(to_ffi, C.for_enum(level)) end |
#confidence(level = :word) ⇒ Object
86 87 88 |
# File 'lib/tesseract/api/iterator.rb', line 86 def confidence (level = :word) C::Iterator.confidence(to_ffi, C.for_enum(level)) end |
#end?(level, element) ⇒ Boolean
46 47 48 |
# File 'lib/tesseract/api/iterator.rb', line 46 def end? (level, element) C::Iterator.is_at_final_element(to_ffi, C.for_enum(level), C.for_enum(element)) end |
#get_binary_image(level = :word) ⇒ Object
58 59 60 |
# File 'lib/tesseract/api/iterator.rb', line 58 def get_binary_image (level = :word) Image.new(C::Iterator.get_binary_image(to_ffi, C.for_enum(level))) end |
#get_image(level = :word, padding = 0) ⇒ Object
62 63 64 65 66 |
# File 'lib/tesseract/api/iterator.rb', line 62 def get_image (level = :word, padding = 0) image = C::Iterator.get_image(to_ffi, C.for_enum(level), padding) Image.new(image.pix, image.x, image.y) end |
#get_text(level = :word) ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/tesseract/api/iterator.rb', line 76 def get_text (level = :word) pointer = C::Iterator.get_utf8_text(to_ffi, C.for_enum(level)) result = pointer.read_string result.force_encoding 'UTF-8' result ensure C.free_array_of_char(pointer) end |
#next(level = :word) ⇒ Object
50 51 52 |
# File 'lib/tesseract/api/iterator.rb', line 50 def next (level = :word) C::Iterator.next(to_ffi, C.for_enum(level)) end |
#orientation ⇒ Object
72 73 74 |
# File 'lib/tesseract/api/iterator.rb', line 72 def orientation C::Iterator.orientation(to_ffi) end |
#symbol_is_dropcap? ⇒ Boolean
114 115 116 |
# File 'lib/tesseract/api/iterator.rb', line 114 def symbol_is_dropcap? C::Iterator.symbol_is_dropcap(to_ffi) end |
#symbol_is_subscript? ⇒ Boolean
110 111 112 |
# File 'lib/tesseract/api/iterator.rb', line 110 def symbol_is_subscript? C::Iterator.symbol_is_subscript(to_ffi) end |
#symbol_is_superscript? ⇒ Boolean
106 107 108 |
# File 'lib/tesseract/api/iterator.rb', line 106 def symbol_is_superscript? C::Iterator.symbol_is_superscript(to_ffi) end |
#to_ffi ⇒ Object
118 119 120 |
# File 'lib/tesseract/api/iterator.rb', line 118 def to_ffi @internal end |
#word_font_attributes ⇒ Object
94 95 96 |
# File 'lib/tesseract/api/iterator.rb', line 94 def word_font_attributes C::Iterator.word_font_attributes(to_ffi) end |