Class: Gcloud::Vision::Annotation::Face::Features::Eye

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

Overview

# Eye

The landmarks of an eye 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 Eyes, 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

right_eye = face.features.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, bottom, center, pupil, top, right) ⇒ Eye



1210
1211
1212
1213
1214
1215
1216
1217
# File 'lib/gcloud/vision/annotation/face.rb', line 1210

def initialize left, bottom, center, pupil, top, right
  @left   = left
  @bottom = bottom
  @center = center
  @pupil  = pupil
  @top    = top
  @right  = right
end

Instance Attribute Details

#bottomLandmark (readonly)

The eye, bottom boundary.



1205
1206
1207
# File 'lib/gcloud/vision/annotation/face.rb', line 1205

def bottom
  @bottom
end

#centerLandmark (readonly)

The eye, center.



1205
1206
1207
# File 'lib/gcloud/vision/annotation/face.rb', line 1205

def center
  @center
end

#leftLandmark (readonly)

The eye, left corner.



1205
1206
1207
# File 'lib/gcloud/vision/annotation/face.rb', line 1205

def left
  @left
end

#pupilLandmark (readonly)

The eye pupil.



1205
1206
1207
# File 'lib/gcloud/vision/annotation/face.rb', line 1205

def pupil
  @pupil
end

#rightLandmark (readonly)

The eye, right corner.



1205
1206
1207
# File 'lib/gcloud/vision/annotation/face.rb', line 1205

def right
  @right
end

#topLandmark (readonly)

The eye, top boundary.



1205
1206
1207
# File 'lib/gcloud/vision/annotation/face.rb', line 1205

def top
  @top
end

Instance Method Details

#inspectObject



1265
1266
1267
# File 'lib/gcloud/vision/annotation/face.rb', line 1265

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

#to_aArray

Returns the object’s property values as an array.



1224
1225
1226
# File 'lib/gcloud/vision/annotation/face.rb', line 1224

def to_a
  to_ary
end

#to_aryArray

Returns the object’s property values as an array.



1233
1234
1235
# File 'lib/gcloud/vision/annotation/face.rb', line 1233

def to_ary
  [left, top, right]
end

#to_hHash

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



1242
1243
1244
# File 'lib/gcloud/vision/annotation/face.rb', line 1242

def to_h
  to_hash
end

#to_hashHash

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



1251
1252
1253
1254
# File 'lib/gcloud/vision/annotation/face.rb', line 1251

def to_hash
  { left: left.to_h, bottom: bottom.to_h, center: center.to_h,
    pupil: pupil.to_h, top: top.to_h, right: right.to_h }
end

#to_sObject



1257
1258
1259
1260
1261
1262
# File 'lib/gcloud/vision/annotation/face.rb', line 1257

def to_s
  tmplt = "(left: %s, bottom: %s, center: %s, " \
            "pupil: %s, top: %s, right: %s)"
  format tmplt, left.inspect, bottom.inspect, center.inspect,
         pupil.inspect, top.inspect, right.inspect
end