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/web.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/crop_hint.rb,
lib/google/cloud/vision/annotation/properties.rb,
lib/google/cloud/vision/annotation/safe_search.rb
Overview
Defined Under Namespace
Classes: CropHint, Entity, Face, Properties, SafeSearch, Text, Vertex, Web
Instance Method Summary collapse
-
#crop_hints ⇒ Array<CropHint>
The results of crop hints detection.
-
#crop_hints? ⇒ Boolean
Whether there is a result for crop hints detection.
-
#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.
-
#web ⇒ Web
The results of web detection.
-
#web? ⇒ Boolean
Whether there is a result for web detection.
Instance Method Details
#crop_hints ⇒ Array<CropHint>
The results of crop hints detection.
415 416 417 418 419 420 421 |
# File 'lib/google/cloud/vision/annotation.rb', line 415 def crop_hints return [] unless @grpc.crop_hints_annotation grpc_crop_hints = @grpc.crop_hints_annotation.crop_hints @crop_hints ||= Array(grpc_crop_hints).map do |ch| CropHint.from_grpc ch end end |
#crop_hints? ⇒ Boolean
Whether there is a result for crop hints detection.
437 438 439 |
# File 'lib/google/cloud/vision/annotation.rb', line 437 def crop_hints? crop_hints.any? end |
#face ⇒ Face
The first face result, if there is one.
91 92 93 |
# File 'lib/google/cloud/vision/annotation.rb', line 91 def face faces.first end |
#face? ⇒ Boolean
Whether there is at least one result from face detection.
109 110 111 |
# File 'lib/google/cloud/vision/annotation.rb', line 109 def face? faces.any? 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(@grpc.face_annotations).map do |fa| Face.from_grpc fa end end |
#label ⇒ Entity
The first label result, if there is one.
264 265 266 |
# File 'lib/google/cloud/vision/annotation.rb', line 264 def label labels.first end |
#label? ⇒ Boolean
Whether there is at least one result from label detection. detection.
283 284 285 |
# File 'lib/google/cloud/vision/annotation.rb', line 283 def label? labels.any? end |
#labels ⇒ Array<Entity>
The results of label detection.
244 245 246 247 248 |
# File 'lib/google/cloud/vision/annotation.rb', line 244 def labels @labels ||= Array(@grpc.label_annotations).map do |lb| Entity.from_grpc lb end end |
#landmark ⇒ Entity
The first landmark result, if there is one.
148 149 150 |
# File 'lib/google/cloud/vision/annotation.rb', line 148 def landmark landmarks.first end |
#landmark? ⇒ Boolean
Whether there is at least one result from landmark detection. detection.
167 168 169 |
# File 'lib/google/cloud/vision/annotation.rb', line 167 def landmark? landmarks.any? end |
#landmarks ⇒ Array<Entity>
The results of landmark detection.
128 129 130 131 132 |
# File 'lib/google/cloud/vision/annotation.rb', line 128 def landmarks @landmarks ||= Array(@grpc.landmark_annotations).map do |lm| Entity.from_grpc lm end end |
#logo ⇒ Entity
The first logo result, if there is one.
206 207 208 |
# File 'lib/google/cloud/vision/annotation.rb', line 206 def logo logos.first end |
#logo? ⇒ Boolean
Whether there is at least one result from logo detection. detection.
225 226 227 |
# File 'lib/google/cloud/vision/annotation.rb', line 225 def logo? logos.any? end |
#logos ⇒ Array<Entity>
The results of logo detection.
186 187 188 189 190 |
# File 'lib/google/cloud/vision/annotation.rb', line 186 def logos @logos ||= Array(@grpc.logo_annotations).map do |lg| Entity.from_grpc lg end end |
#properties ⇒ Properties?
The results of properties detection.
376 377 378 379 380 381 |
# File 'lib/google/cloud/vision/annotation.rb', line 376 def properties return nil unless @grpc.image_properties_annotation @properties ||= Properties.from_grpc( @grpc.image_properties_annotation ) end |
#properties? ⇒ Boolean
Whether there is a result for properties detection.
397 398 399 |
# File 'lib/google/cloud/vision/annotation.rb', line 397 def properties? !properties.nil? end |
#safe_search ⇒ SafeSearch?
The results of safe_search detection.
338 339 340 341 |
# File 'lib/google/cloud/vision/annotation.rb', line 338 def safe_search return nil unless @grpc.safe_search_annotation @safe_search ||= SafeSearch.from_grpc(@grpc.safe_search_annotation) end |
#safe_search? ⇒ Boolean
Whether there is a result for safe_search detection. detection.
358 359 360 |
# File 'lib/google/cloud/vision/annotation.rb', line 358 def safe_search? !safe_search.nil? end |
#text ⇒ Text
The results of text (OCR) detection.
301 302 303 304 |
# File 'lib/google/cloud/vision/annotation.rb', line 301 def text @text ||= \ Text.from_grpc(@grpc.text_annotations, @grpc.full_text_annotation) end |
#text? ⇒ Boolean
Whether there is a result from text (OCR) detection.
320 321 322 |
# File 'lib/google/cloud/vision/annotation.rb', line 320 def text? !text.nil? end |
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
483 484 485 486 487 488 489 |
# File 'lib/google/cloud/vision/annotation.rb', line 483 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.to_h, safe_search: safe_search.to_h, properties: properties.to_h, crop_hints: crop_hints.map(&:to_h), web: web.to_h } end |
#web ⇒ Web
The results of web detection.
455 456 457 458 |
# File 'lib/google/cloud/vision/annotation.rb', line 455 def web return nil unless @grpc.web_detection @web ||= Web.from_grpc(@grpc.web_detection) end |
#web? ⇒ Boolean
Whether there is a result for web detection.
474 475 476 |
# File 'lib/google/cloud/vision/annotation.rb', line 474 def web? !web.nil? end |