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.
77 78 79 80 81 82 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 77 def bounds return [] unless @grpc.bounding_poly @bounds ||= Array(@grpc.bounding_poly.vertices).map do |v| Vertex.from_grpc v end end |
#locale ⇒ String
The language code detected for text
.
68 69 70 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 68 def locale @grpc.locale end |
#text ⇒ String
The text detected in an image.
57 58 59 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 57 def text @grpc.description end |
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
98 99 100 101 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 98 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.
89 90 91 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 89 def words @words end |