Class: Google::Cloud::Vision::Annotation::Vertex

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

Overview

# Vertex

A vertex in a set of bounding polygon vertices.

See Face::Bounds and Text.

Examples:

require "google/cloud/vision"

vision = Google::Cloud::Vision.new

image = vision.image "path/to/text.png"
text = image.text

text.bounds.count #=> 4
vertex = text.bounds.first
vertex.x #=> 13
vertex.y #=> 8

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y) ⇒ Vertex

Returns a new instance of Vertex.



48
49
50
51
# File 'lib/google/cloud/vision/annotation/vertex.rb', line 48

def initialize x, y
  @x = x
  @y = y
end

Instance Attribute Details

#xInteger (readonly)

The X coordinate.

Returns:

  • (Integer)

    the current value of x



43
44
45
# File 'lib/google/cloud/vision/annotation/vertex.rb', line 43

def x
  @x
end

#yInteger (readonly)

The Y coordinate.

Returns:

  • (Integer)

    the current value of y



43
44
45
# File 'lib/google/cloud/vision/annotation/vertex.rb', line 43

def y
  @y
end

Class Method Details

.from_grpc(grpc) ⇒ Object

Client object.



84
85
86
# File 'lib/google/cloud/vision/annotation/vertex.rb', line 84

def self.from_grpc grpc
  new grpc.x, grpc.y
end

Instance Method Details

#inspectObject



77
78
79
# File 'lib/google/cloud/vision/annotation/vertex.rb', line 77

def inspect
  "#<Vertex #{self}>"
end

#to_aArray

Returns the object’s property values as an array.

Returns:

  • (Array)


58
59
60
# File 'lib/google/cloud/vision/annotation/vertex.rb', line 58

def to_a
  [x, y]
end

#to_hHash

Converts object to a hash. All keys will be symbolized.

Returns:

  • (Hash)


67
68
69
# File 'lib/google/cloud/vision/annotation/vertex.rb', line 67

def to_h
  { x: x, y: y }
end

#to_sObject



72
73
74
# File 'lib/google/cloud/vision/annotation/vertex.rb', line 72

def to_s
  "(x: #{x.inspect}, y: #{y.inspect})"
end