Class: Google::Cloud::Vision::Annotation::Text
- Inherits:
-
Object
- Object
- Google::Cloud::Vision::Annotation::Text
- Defined in:
- lib/google/cloud/vision/annotation/text.rb
Overview
Text
The result of text, or optical character recognition (OCR), detection.
Defined Under Namespace
Classes: Word
Instance Method Summary collapse
-
#bounds ⇒ Array<Vertex>
The bounds for the detected text in the image.
-
#locale ⇒ String
The language code detected for
text
. -
#text ⇒ String
The text detected in an image.
-
#to_h ⇒ Hash
Deeply converts object to a hash.
-
#words ⇒ Array<Word>
Each word in the detected text, with the bounds for each word.
Instance Method Details
#bounds ⇒ Array<Vertex>
The bounds for the detected text in the image.
78 79 80 81 82 83 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 78 def bounds return [] unless @gapi.bounding_poly @bounds ||= Array(@gapi.bounding_poly.vertices).map do |v| Vertex.from_gapi v end end |
#locale ⇒ String
The language code detected for text
.
69 70 71 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 69 def locale @gapi.locale end |
#text ⇒ String
The text detected in an image.
58 59 60 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 58 def text @gapi.description end |
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
99 100 101 102 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 99 def to_h { text: text, locale: locale, bounds: bounds.map(&:to_h), words: words.map(&:to_h) } end |
#words ⇒ Array<Word>
Each word in the detected text, with the bounds for each word.
90 91 92 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 90 def words @words end |