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 results from either the TEXT_DETECTION feature (OCR for shorter
documents with sparse text) or the DOCUMENT_TEXT_DETECTION feature
(OCR for longer documents with dense text). Optional. Contains
structured representations of OCR extracted text, as well as
the entire UTF-8 text as a string.
Defined Under Namespace
Instance Method Summary collapse
- 
  
    
      #bounds  ⇒ Array<Vertex> 
    
    
  
  
  
  
  
  
  
  
  
    
The bounds for the detected text in the image.
 - 
  
    
      #locale  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
The language code detected for
text. - 
  
    
      #pages  ⇒ Array<Page> 
    
    
  
  
  
  
  
  
  
  
  
    
Each page in the detected text, with the metadata for each page.
 - 
  
    
      #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.
      90 91 92 93 94 95  | 
    
      # File 'lib/google/cloud/vision/annotation/text.rb', line 90 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.
      81 82 83  | 
    
      # File 'lib/google/cloud/vision/annotation/text.rb', line 81 def locale @grpc.locale end  | 
  
#pages ⇒ Array<Page>
Each page in the detected text, with the metadata for each page. Contains a structured representation of OCR extracted text. The hierarchy of an OCR extracted text structure is like this: Page -> Block -> Paragraph -> Word -> Symbol Each structural component, starting from Page, may further have its own properties. Properties describe detected languages, breaks etc..
      116 117 118  | 
    
      # File 'lib/google/cloud/vision/annotation/text.rb', line 116 def pages @pages end  | 
  
#text ⇒ String
The text detected in an image.
      70 71 72  | 
    
      # File 'lib/google/cloud/vision/annotation/text.rb', line 70 def text @grpc.description end  | 
  
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
      125 126 127 128  | 
    
      # File 'lib/google/cloud/vision/annotation/text.rb', line 125 def to_h { text: text, locale: locale, bounds: bounds.map(&:to_h), words: words.map(&:to_h), pages: pages.map(&:to_h) } end  | 
  
#words ⇒ Array<Word>
Each word in the detected text, with the bounds for each word.
      102 103 104  | 
    
      # File 'lib/google/cloud/vision/annotation/text.rb', line 102 def words @words end  |