Class: Gcloud::Vision::Annotation::Face::Features::Eyes

Inherits:
Object
  • Object
show all
Defined in:
lib/gcloud/vision/annotation/face.rb

Overview

# Eyes

The landmarks of the eyes in the features of a face.

Left and right are defined from the vantage of the viewer of the image, without considering mirror projections typical of photos. So face.features.eyes.left typically is the person’s right eye.

See Gcloud::Vision::Annotation::Face::Features and Gcloud::Vision::Annotation::Face.

Examples:

require "gcloud"

gcloud = Gcloud.new
vision = gcloud.vision

image = vision.image "path/to/face.jpg"
face = image.face

eyes = face.features.eyes

right_eye = eyes.right
right_eye.pupil
#=> #<Landmark (x: 256.63464, y: 79.641411, z: -6.0731235)>

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, right) ⇒ Eyes

Returns a new instance of Eyes.



1118
1119
1120
1121
# File 'lib/gcloud/vision/annotation/face.rb', line 1118

def initialize left, right
  @left  = left
  @right = right
end

Instance Attribute Details

#leftEye (readonly)

The left eye.

Returns:

  • (Eye)

    the current value of left



1113
1114
1115
# File 'lib/gcloud/vision/annotation/face.rb', line 1113

def left
  @left
end

#rightEye (readonly)

The right eye.

Returns:

  • (Eye)

    the current value of right



1113
1114
1115
# File 'lib/gcloud/vision/annotation/face.rb', line 1113

def right
  @right
end

Instance Method Details

#inspectObject



1165
1166
1167
# File 'lib/gcloud/vision/annotation/face.rb', line 1165

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

#to_aArray

Returns the object’s property values as an array.

Returns:

  • (Array)


1128
1129
1130
# File 'lib/gcloud/vision/annotation/face.rb', line 1128

def to_a
  to_ary
end

#to_aryArray

Returns the object’s property values as an array.

Returns:

  • (Array)


1137
1138
1139
# File 'lib/gcloud/vision/annotation/face.rb', line 1137

def to_ary
  [left, right]
end

#to_hHash

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

Returns:

  • (Hash)


1146
1147
1148
# File 'lib/gcloud/vision/annotation/face.rb', line 1146

def to_h
  to_hash
end

#to_hashHash

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

Returns:

  • (Hash)


1155
1156
1157
# File 'lib/gcloud/vision/annotation/face.rb', line 1155

def to_hash
  { left: left.to_h, right: right.to_h }
end

#to_sObject



1160
1161
1162
# File 'lib/gcloud/vision/annotation/face.rb', line 1160

def to_s
  "(left: #{left.inspect}, right: #{right.inspect})"
end