Class: Google::Cloud::Vision::Image::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/vision/image.rb

Overview

Image::Context

Represents an image context.

Examples:

require "google/cloud/vision"

vision = Google::Cloud::Vision.new

image = vision.image "path/to/landmark.jpg"
image.context.area.min = { longitude: -122.0862462,
                           latitude: 37.4220041 }
image.context.area.max = { longitude: -122.0762462,
                           latitude: 37.4320041 }

Defined Under Namespace

Classes: Area

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#areaArea (readonly)

Returns a lat/long rectangle that specifies the location of the image.

Returns:

  • (Area)

    The lat/long pairs for latLongRect.



661
662
663
# File 'lib/google/cloud/vision/image.rb', line 661

def area
  @area
end

#aspect_ratiosArray<Float>

Aspect ratios in floats, representing the ratio of the width to the height of the image. For example, if the desired aspect ratio is 4/3, the corresponding float value should be 1.33333. If not specified, the best possible crop is returned. The number of provided aspect ratios is limited to a maximum of 16; any aspect ratios provided after the 16th are ignored. For use with Google::Cloud::Vision::Image#crop_hints.

Returns:

  • (Array<Float>)

    the current value of aspect_ratios



656
657
658
# File 'lib/google/cloud/vision/image.rb', line 656

def aspect_ratios
  @aspect_ratios
end

#languagesArray<String>

A list of ISO 639-1 language 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). For use with Google::Cloud::Vision::Image#text.

Returns:

  • (Array<String>)

    the current value of languages



656
657
658
# File 'lib/google/cloud/vision/image.rb', line 656

def languages
  @languages
end

Instance Method Details

#empty?Boolean

Returns true if either min or max are not populated.

Returns:

  • (Boolean)


678
679
680
# File 'lib/google/cloud/vision/image.rb', line 678

def empty?
  area.empty? && languages.empty? && aspect_ratios.empty?
end