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

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

Overview

Landmark

A face-specific landmark (for example, a face feature). Landmark positions may fall outside the bounds of the image when the face is near one or more edges of the image. Therefore it is NOT guaranteed that 0 <= x < width or 0 <= y < height.

See 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

face.features.to_h.count #=> 9
face.features.eyes.left.pupil
#=> #<Landmark (x: 190.41544, y: 84.4557, z: -1.3682901)>
face.features.chin.center
#=> #<Landmark (x: 233.21977, y: 189.47475, z: 19.487228)>

Instance Method Summary collapse

Instance Method Details

#to_aArray

Returns the object's property values as an array.

Returns:

  • (Array)


619
620
621
# File 'lib/google/cloud/vision/annotation/face.rb', line 619

def to_a
  [x, y, z]
end

#to_hHash

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

Returns:

  • (Hash)


628
629
630
# File 'lib/google/cloud/vision/annotation/face.rb', line 628

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

#typeString

The landmark type code.

Examples:

require "google/cloud/vision"

vision = Google::Cloud::Vision.new

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

face.features.forehead.type #=> "FOREHEAD_GLABELLA"

Returns:

  • (String)

See Also:



580
581
582
# File 'lib/google/cloud/vision/annotation/face.rb', line 580

def type
  @grpc.type
end

#xFloat

The X (horizontal) coordinate.

Returns:

  • (Float)


589
590
591
592
# File 'lib/google/cloud/vision/annotation/face.rb', line 589

def x
  return nil unless @grpc.position
  @grpc.position.x
end

#yFloat

The Y (vertical) coordinate.

Returns:

  • (Float)


599
600
601
602
# File 'lib/google/cloud/vision/annotation/face.rb', line 599

def y
  return nil unless @grpc.position
  @grpc.position.y
end

#zFloat

The Z (depth) coordinate.

Returns:

  • (Float)


609
610
611
612
# File 'lib/google/cloud/vision/annotation/face.rb', line 609

def z
  return nil unless @grpc.position
  @grpc.position.z
end