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

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

Overview

Image::Context::Area

A Lat/long rectangle that specifies the location of the image.

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 }

entity = image.landmark

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#maxLocation

Returns the max lat/long pair.

Returns:



499
500
501
# File 'lib/google/cloud/vision/image.rb', line 499

def max
  @max
end

#minLocation

Returns the min lat/long pair.

Returns:



495
496
497
# File 'lib/google/cloud/vision/image.rb', line 495

def min
  @min
end

Instance Method Details

#empty?Boolean

Returns true if either min or max are not populated.

Returns:

  • (Boolean)


545
546
547
548
# File 'lib/google/cloud/vision/image.rb', line 545

def empty?
  min.to_h.values.reject(&:nil?).empty? ||
    max.to_h.values.reject(&:nil?).empty?
end

#to_grpcObject



559
560
561
562
563
564
565
# File 'lib/google/cloud/vision/image.rb', line 559

def to_grpc
  return nil if empty?
  Google::Cloud::Vision::V1::LatLongRect.new(
    min_lat_lng: min.to_grpc,
    max_lat_lng: max.to_grpc
  )
end

#to_hHash

Deeply converts object to a hash. All keys will be symbolized.

Returns:

  • (Hash)


555
556
557
# File 'lib/google/cloud/vision/image.rb', line 555

def to_h
  { min_lat_lng: min.to_h, max_lat_lng: max.to_h }
end