Class: Google::Cloud::Vision::Annotation::Face::Features::Eye

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/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, Google::Cloud::Vision::Annotation::Face::Features and Google::Cloud::Vision::Annotation::Face.

Examples:

require "google/cloud/vision"

vision = Google::Cloud::Vision.new

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

Returns a new instance of Eye.



1039
1040
1041
1042
1043
1044
1045
1046
# File 'lib/google/cloud/vision/annotation/face.rb', line 1039

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.

Returns:

  • (Landmark)

    the current value of bottom



1034
1035
1036
# File 'lib/google/cloud/vision/annotation/face.rb', line 1034

def bottom
  @bottom
end

#centerLandmark (readonly)

The eye, center.

Returns:

  • (Landmark)

    the current value of center



1034
1035
1036
# File 'lib/google/cloud/vision/annotation/face.rb', line 1034

def center
  @center
end

#leftLandmark (readonly)

The eye, left corner.

Returns:

  • (Landmark)

    the current value of left



1034
1035
1036
# File 'lib/google/cloud/vision/annotation/face.rb', line 1034

def left
  @left
end

#pupilLandmark (readonly)

The eye pupil.

Returns:

  • (Landmark)

    the current value of pupil



1034
1035
1036
# File 'lib/google/cloud/vision/annotation/face.rb', line 1034

def pupil
  @pupil
end

#rightLandmark (readonly)

The eye, right corner.

Returns:

  • (Landmark)

    the current value of right



1034
1035
1036
# File 'lib/google/cloud/vision/annotation/face.rb', line 1034

def right
  @right
end

#topLandmark (readonly)

The eye, top boundary.

Returns:

  • (Landmark)

    the current value of top



1034
1035
1036
# File 'lib/google/cloud/vision/annotation/face.rb', line 1034

def top
  @top
end

Instance Method Details

#inspectObject



1076
1077
1078
# File 'lib/google/cloud/vision/annotation/face.rb', line 1076

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

#to_aArray

Returns the object’s property values as an array.

Returns:

  • (Array)


1053
1054
1055
# File 'lib/google/cloud/vision/annotation/face.rb', line 1053

def to_a
  [left, top, right]
end

#to_hHash

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

Returns:

  • (Hash)


1062
1063
1064
1065
# File 'lib/google/cloud/vision/annotation/face.rb', line 1062

def to_h
  { 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



1068
1069
1070
1071
1072
1073
# File 'lib/google/cloud/vision/annotation/face.rb', line 1068

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