Class: Gcp::Vision::Annotation

Inherits:
Object
  • Object
show all
Defined in:
lib/gcp/vision/annotation.rb

Defined Under Namespace

Classes: ImageProperty, Label

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ Annotation

Returns a new instance of Annotation.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/gcp/vision/annotation.rb', line 6

def initialize(result)
  @annotations = {}
  result.each do |type, annotations|
    @annotations[type] = case type
                        when "labelAnnotations"
                          annotations.map { |annotation| Gcp::Vision::Annotation::Label.new(annotation) }
                        when "imagePropertiesAnnotation"
                          annotations["dominantColors"]["colors"].map { |annotation| Gcp::Vision::Annotation::ImageProperty.new(annotation) }
                        else
                          annotations
                        end
  end
end

Instance Attribute Details

#annotationsObject (readonly)

Returns the value of attribute annotations.



4
5
6
# File 'lib/gcp/vision/annotation.rb', line 4

def annotations
  @annotations
end