Class: Google::Cloud::Vision::Annotation::Face::Features
- Inherits:
-
Object
- Object
- Google::Cloud::Vision::Annotation::Face::Features
- Defined in:
- lib/google/cloud/vision/annotation/face.rb
Overview
Features
Represents facial landmarks or features. 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.
Defined Under Namespace
Classes: Chin, Ears, Eye, Eyebrow, Eyebrows, Eyes, Landmark, Lips, Mouth, Nose
Instance Method Summary collapse
-
#[](landmark_type) ⇒ Landmark
Returns the facial landmark for the provided type code.
-
#chin ⇒ Chin
The landmarks of the chin.
-
#confidence ⇒ Float
The confidence of the facial landmarks detection.
-
#ears ⇒ Ears
The landmarks of the ears.
-
#eyebrows ⇒ Eyebrows
The landmarks of the eyebrows.
-
#eyes ⇒ Eyes
The landmarks of the eyes.
-
#forehead ⇒ Landmark
The landmark for the forehead glabella.
-
#lips ⇒ Lips
The landmarks of the lips.
-
#mouth ⇒ Mouth
The landmarks of the mouth.
-
#nose ⇒ Nose
The landmarks of the nose.
-
#to_h ⇒ Hash
Deeply converts object to a hash.
Instance Method Details
#[](landmark_type) ⇒ Landmark
Returns the facial landmark for the provided type code.
394 395 396 397 398 399 400 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 394 def [] landmark_type landmark = Array(@gapi.landmarks).detect do |l| l.type == landmark_type end return nil if landmark.nil? Landmark.from_gapi landmark end |
#chin ⇒ Chin
The landmarks of the chin.
407 408 409 410 411 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 407 def chin @chin ||= Chin.new self["CHIN_LEFT_GONION"], self["CHIN_GNATHION"], self["CHIN_RIGHT_GONION"] end |
#confidence ⇒ Float
The confidence of the facial landmarks detection.
366 367 368 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 366 def confidence @gapi.landmarking_confidence end |
#ears ⇒ Ears
The landmarks of the ears.
418 419 420 421 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 418 def ears @ears ||= Ears.new self["LEFT_EAR_TRAGION"], self["RIGHT_EAR_TRAGION"] end |
#eyebrows ⇒ Eyebrows
The landmarks of the eyebrows.
428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 428 def eyebrows @eyebrows ||= begin left = Eyebrow.new self["LEFT_OF_LEFT_EYEBROW"], self["LEFT_EYEBROW_UPPER_MIDPOINT"], self["RIGHT_OF_LEFT_EYEBROW"] right = Eyebrow.new self["LEFT_OF_RIGHT_EYEBROW"], self["RIGHT_EYEBROW_UPPER_MIDPOINT"], self["RIGHT_OF_RIGHT_EYEBROW"] Eyebrows.new left, right end end |
#eyes ⇒ Eyes
The landmarks of the eyes.
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 445 def eyes @eyes ||= begin left = Eye.new self["LEFT_EYE_LEFT_CORNER"], self["LEFT_EYE_BOTTOM_BOUNDARY"], self["LEFT_EYE"], self["LEFT_EYE_PUPIL"], self["LEFT_EYE_TOP_BOUNDARY"], self["LEFT_EYE_RIGHT_CORNER"] right = Eye.new self["RIGHT_EYE_LEFT_CORNER"], self["RIGHT_EYE_BOTTOM_BOUNDARY"], self["RIGHT_EYE"], self["RIGHT_EYE_PUPIL"], self["RIGHT_EYE_TOP_BOUNDARY"], self["RIGHT_EYE_RIGHT_CORNER"] Eyes.new left, right end end |
#forehead ⇒ Landmark
The landmark for the forehead glabella.
466 467 468 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 466 def forehead @forehead ||= self["FOREHEAD_GLABELLA"] end |
#lips ⇒ Lips
The landmarks of the lips.
475 476 477 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 475 def lips @lips ||= Lips.new self["UPPER_LIP"], self["LOWER_LIP"] end |
#mouth ⇒ Mouth
The landmarks of the mouth.
484 485 486 487 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 484 def mouth @mouth ||= Mouth.new self["MOUTH_LEFT"], self["MOUTH_CENTER"], self["MOUTH_RIGHT"] end |
#nose ⇒ Nose
The landmarks of the nose.
494 495 496 497 498 499 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 494 def nose @nose ||= Nose.new self["NOSE_BOTTOM_LEFT"], self["NOSE_BOTTOM_CENTER"], self["NOSE_TIP"], self["MIDPOINT_BETWEEN_EYES"], self["NOSE_BOTTOM_RIGHT"] end |
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
506 507 508 509 510 511 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 506 def to_h { confidence: confidence, chin: chin.to_h, ears: ears.to_h, eyebrows: eyebrows.to_h, eyes: eyes.to_h, forehead: forehead.to_h, lips: lips.to_h, mouth: mouth.to_h, nose: nose.to_h } end |