Class: Google::Cloud::Vision::Annotation
- Inherits:
-
Object
- Object
- Google::Cloud::Vision::Annotation
- Defined in:
- lib/google/cloud/vision/annotation.rb,
lib/google/cloud/vision/annotation/face.rb,
lib/google/cloud/vision/annotation/text.rb,
lib/google/cloud/vision/annotation/entity.rb,
lib/google/cloud/vision/annotation/vertex.rb,
lib/google/cloud/vision/annotation/properties.rb,
lib/google/cloud/vision/annotation/safe_search.rb
Overview
Defined Under Namespace
Classes: Entity, Face, Properties, SafeSearch, Text, Vertex
Instance Method Summary collapse
-
#face ⇒ Face
The first face result, if there is one.
-
#face? ⇒ Boolean
Whether there is at least one result from face detection.
-
#faces ⇒ Array<Face>
The results of face detection.
-
#label ⇒ Entity
The first label result, if there is one.
-
#label? ⇒ Boolean
Whether there is at least one result from label detection.
-
#labels ⇒ Array<Entity>
The results of label detection.
-
#landmark ⇒ Entity
The first landmark result, if there is one.
-
#landmark? ⇒ Boolean
Whether there is at least one result from landmark detection.
-
#landmarks ⇒ Array<Entity>
The results of landmark detection.
-
#logo ⇒ Entity
The first logo result, if there is one.
-
#logo? ⇒ Boolean
Whether there is at least one result from logo detection.
-
#logos ⇒ Array<Entity>
The results of logo detection.
-
#properties ⇒ Properties
The results of properties detection.
-
#properties? ⇒ Boolean
Whether there is a result for properties detection.
-
#safe_search ⇒ SafeSearch
The results of safe_search detection.
-
#safe_search? ⇒ Boolean
Whether there is a result for safe_search detection.
-
#text ⇒ Text
The results of text (OCR) detection.
-
#text? ⇒ Boolean
Whether there is a result from text (OCR) detection.
-
#to_h ⇒ Hash
Deeply converts object to a hash.
Instance Method Details
#face ⇒ Face
The first face result, if there is one.
92 93 94 |
# File 'lib/google/cloud/vision/annotation.rb', line 92 def face faces.first end |
#face? ⇒ Boolean
Whether there is at least one result from face detection.
111 112 113 |
# File 'lib/google/cloud/vision/annotation.rb', line 111 def face? faces.count > 0 end |
#faces ⇒ Array<Face>
The results of face detection.
71 72 73 74 75 |
# File 'lib/google/cloud/vision/annotation.rb', line 71 def faces @faces ||= Array(@gapi.face_annotations).map do |fa| Face.from_gapi fa end end |
#label ⇒ Entity
The first label result, if there is one.
274 275 276 |
# File 'lib/google/cloud/vision/annotation.rb', line 274 def label labels.first end |
#label? ⇒ Boolean
Whether there is at least one result from label detection. detection.
294 295 296 |
# File 'lib/google/cloud/vision/annotation.rb', line 294 def label? labels.count > 0 end |
#labels ⇒ Array<Entity>
The results of label detection.
253 254 255 256 257 |
# File 'lib/google/cloud/vision/annotation.rb', line 253 def labels @labels ||= Array(@gapi.label_annotations).map do |lb| Entity.from_gapi lb end end |
#landmark ⇒ Entity
The first landmark result, if there is one.
152 153 154 |
# File 'lib/google/cloud/vision/annotation.rb', line 152 def landmark landmarks.first end |
#landmark? ⇒ Boolean
Whether there is at least one result from landmark detection. detection.
172 173 174 |
# File 'lib/google/cloud/vision/annotation.rb', line 172 def landmark? landmarks.count > 0 end |
#landmarks ⇒ Array<Entity>
The results of landmark detection.
131 132 133 134 135 |
# File 'lib/google/cloud/vision/annotation.rb', line 131 def landmarks @landmarks ||= Array(@gapi.landmark_annotations).map do |lm| Entity.from_gapi lm end end |
#logo ⇒ Entity
The first logo result, if there is one.
213 214 215 |
# File 'lib/google/cloud/vision/annotation.rb', line 213 def logo logos.first end |
#logo? ⇒ Boolean
Whether there is at least one result from logo detection. detection.
233 234 235 |
# File 'lib/google/cloud/vision/annotation.rb', line 233 def logo? logos.count > 0 end |
#logos ⇒ Array<Entity>
The results of logo detection.
192 193 194 195 196 |
# File 'lib/google/cloud/vision/annotation.rb', line 192 def logos @logos ||= Array(@gapi.logo_annotations).map do |lg| Entity.from_gapi lg end end |
#properties ⇒ Properties
The results of properties detection.
391 392 393 394 395 |
# File 'lib/google/cloud/vision/annotation.rb', line 391 def properties return nil unless @gapi.image_properties_annotation @properties ||= Properties.from_gapi( @gapi.image_properties_annotation) end |
#properties? ⇒ Boolean
Whether there is a result for properties detection.
412 413 414 |
# File 'lib/google/cloud/vision/annotation.rb', line 412 def properties? !properties.nil? end |
#safe_search ⇒ SafeSearch
The results of safe_search detection.
351 352 353 354 |
# File 'lib/google/cloud/vision/annotation.rb', line 351 def safe_search return nil unless @gapi.safe_search_annotation @safe_search ||= SafeSearch.from_gapi(@gapi.safe_search_annotation) end |
#safe_search? ⇒ Boolean
Whether there is a result for safe_search detection. detection.
372 373 374 |
# File 'lib/google/cloud/vision/annotation.rb', line 372 def safe_search? !safe_search.nil? end |
#text ⇒ Text
The results of text (OCR) detection.
313 314 315 |
# File 'lib/google/cloud/vision/annotation.rb', line 313 def text @text ||= Text.from_gapi(@gapi.text_annotations) end |
#text? ⇒ Boolean
Whether there is a result from text (OCR) detection.
332 333 334 |
# File 'lib/google/cloud/vision/annotation.rb', line 332 def text? !text.nil? end |
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
421 422 423 424 425 426 |
# File 'lib/google/cloud/vision/annotation.rb', line 421 def to_h { faces: faces.map(&:to_h), landmarks: landmarks.map(&:to_h), logos: logos.map(&:to_h), labels: labels.map(&:to_h), text: text.map(&:to_h), safe_search: safe_search.to_h, properties: properties.to_h } end |