Class: Gcloud::Vision::Annotation::Face::Angles

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

Overview

# Angles

The orientation of the face relative to the image.

See Gcloud::Vision::Annotation::Face.

Examples:

require "gcloud"

gcloud = Gcloud.new
vision = gcloud.vision

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

face.angles.roll #=> -5.1492119
face.angles.yaw #=> -4.0695682
face.angles.pitch #=> -13.083284

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAngles

Returns a new instance of Angles.



160
161
162
# File 'lib/gcloud/vision/annotation/face.rb', line 160

def initialize
  @gapi = {}
end

Instance Attribute Details

#gapiObject



156
157
158
# File 'lib/gcloud/vision/annotation/face.rb', line 156

def gapi
  @gapi
end

Class Method Details

.from_gapi(gapi) ⇒ Object

object.



248
249
250
# File 'lib/gcloud/vision/annotation/face.rb', line 248

def self.from_gapi gapi
  new.tap { |f| f.instance_variable_set :@gapi, gapi }
end

Instance Method Details

#inspectObject



241
242
243
# File 'lib/gcloud/vision/annotation/face.rb', line 241

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

#pitchFloat Also known as: tilt

Pitch (tilt) angle. Indicates the upwards/downwards angle that the face is pointing relative to the image’s horizontal plane.

Returns:

  • (Float)

    A value in the range [-180,180].



193
194
195
# File 'lib/gcloud/vision/annotation/face.rb', line 193

def pitch
  @gapi["tiltAngle"]
end

#rollFloat

Roll angle. Indicates the amount of clockwise/anti-clockwise rotation of the face relative to the image vertical, about the axis perpendicular to the face.

Returns:

  • (Float)

    A value in the range [-180,180].



171
172
173
# File 'lib/gcloud/vision/annotation/face.rb', line 171

def roll
  @gapi["rollAngle"]
end

#to_aArray

Returns the object’s property values as an array.

Returns:

  • (Array)


203
204
205
# File 'lib/gcloud/vision/annotation/face.rb', line 203

def to_a
  to_ary
end

#to_aryArray

Returns the object’s property values as an array.

Returns:

  • (Array)


212
213
214
# File 'lib/gcloud/vision/annotation/face.rb', line 212

def to_ary
  [roll, yaw, pitch]
end

#to_hHash

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

Returns:

  • (Hash)


221
222
223
# File 'lib/gcloud/vision/annotation/face.rb', line 221

def to_h
  to_hash
end

#to_hashHash

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

Returns:

  • (Hash)


230
231
232
# File 'lib/gcloud/vision/annotation/face.rb', line 230

def to_hash
  { roll: roll, yaw: yaw, pitch: pitch }
end

#to_sObject



235
236
237
238
# File 'lib/gcloud/vision/annotation/face.rb', line 235

def to_s
  format "(roll: %s, yaw: %s, pitch: %s)", roll.inspect, yaw.inspect,
         pitch.inspect
end

#yawFloat Also known as: pan

Yaw (pan) angle. Indicates the leftward/rightward angle that the face is pointing, relative to the vertical plane perpendicular to the image.

Returns:

  • (Float)

    A value in the range [-180,180].



182
183
184
# File 'lib/gcloud/vision/annotation/face.rb', line 182

def yaw
  @gapi["panAngle"]
end