Class: Gcloud::Vision::Image::Context
- Inherits:
-
Object
- Object
- Gcloud::Vision::Image::Context
- Defined in:
- lib/gcloud/vision/image.rb
Overview
# Image::Context
Represents an image context.
Defined Under Namespace
Classes: Area
Instance Attribute Summary collapse
-
#area ⇒ Area
readonly
Returns a lat/long rectangle that specifies the location of the image.
-
#languages ⇒ Array<String>
A list of [ISO 639-1 language codes](en.wikipedia.org/wiki/List_of_ISO_639-1_codes) to use for text (OCR) detection.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Returns ‘true` if either `min` or `max` are not populated.
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #to_gapi ⇒ Object
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context.
459 460 461 462 |
# File 'lib/gcloud/vision/image.rb', line 459 def initialize @area = Area.new @languages = [] end |
Instance Attribute Details
#area ⇒ Area (readonly)
Returns a lat/long rectangle that specifies the location of the image.
453 454 455 |
# File 'lib/gcloud/vision/image.rb', line 453 def area @area end |
#languages ⇒ Array<String>
A list of [ISO 639-1 language codes](en.wikipedia.org/wiki/List_of_ISO_639-1_codes) to use for text (OCR) detection. In most cases, an empty value will yield the best results as it will allow text detection to automatically detect the text language. For languages based on the latin alphabet a hint is not needed. In rare cases, when the language of the text in the image is known in advance, setting this hint will help get better results (although it will hurt a great deal if the hint is wrong).
450 451 452 |
# File 'lib/gcloud/vision/image.rb', line 450 def languages @languages end |
Instance Method Details
#empty? ⇒ Boolean
Returns ‘true` if either `min` or `max` are not populated.
469 470 471 |
# File 'lib/gcloud/vision/image.rb', line 469 def empty? area.empty? && languages.empty? end |
#to_gapi ⇒ Object
475 476 477 478 479 480 481 |
# File 'lib/gcloud/vision/image.rb', line 475 def to_gapi return nil if empty? gapi = Google::Apis::VisionV1::ImageContext.new gapi.lat_long_rect = area.to_gapi unless area.empty? gapi.language_hints = languages unless languages.empty? gapi end |