Class: Google::Cloud::Vision::Annotation::Face::Likelihood

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

Overview

Likelihood

A bucketized representation of likelihood of various separate facial characteristics, meant to give highly stable results across model upgrades.

See Google::Cloud::Vision::Annotation::Face.

Examples:

require "google/cloud"

gcloud = Google::Cloud.new
vision = gcloud.vision

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

face.likelihood.to_h.count #=> 7
face.likelihood.sorrow? #=> false
face.likelihood.sorrow #=> "VERY_UNLIKELY"

See Also:

Constant Summary collapse

POSITIVE_RATINGS =
%w(POSSIBLE LIKELY VERY_LIKELY)

Instance Method Summary collapse

Instance Method Details

#angerObject

Joy likelihood rating. Possible values are VERY_UNLIKELY, UNLIKELY, POSSIBLE, LIKELY, and VERY_LIKELY.



1392
1393
1394
# File 'lib/google/cloud/vision/annotation/face.rb', line 1392

def anger
  @gapi.anger_likelihood
end

#anger?Boolean

Anger likelihood. Returns true if #anger is POSSIBLE, LIKELY, or VERY_LIKELY.

Returns:

  • (Boolean)


1402
1403
1404
# File 'lib/google/cloud/vision/annotation/face.rb', line 1402

def anger?
  POSITIVE_RATINGS.include? anger
end

#blurredObject

Blurred likelihood rating. Possible values are VERY_UNLIKELY, UNLIKELY, POSSIBLE, LIKELY, and VERY_LIKELY.



1444
1445
1446
# File 'lib/google/cloud/vision/annotation/face.rb', line 1444

def blurred
  @gapi.blurred_likelihood
end

#blurred?Boolean

Blurred likelihood. Returns true if #blurred is POSSIBLE, LIKELY, or VERY_LIKELY.

Returns:

  • (Boolean)


1454
1455
1456
# File 'lib/google/cloud/vision/annotation/face.rb', line 1454

def blurred?
  POSITIVE_RATINGS.include? blurred
end

#headwearObject

Headwear likelihood rating. Possible values are VERY_UNLIKELY, UNLIKELY, POSSIBLE, LIKELY, and VERY_LIKELY.



1461
1462
1463
# File 'lib/google/cloud/vision/annotation/face.rb', line 1461

def headwear
  @gapi.headwear_likelihood
end

#headwear?Boolean

Headwear likelihood. Returns true if #headwear is POSSIBLE, LIKELY, or VERY_LIKELY.

Returns:

  • (Boolean)


1471
1472
1473
# File 'lib/google/cloud/vision/annotation/face.rb', line 1471

def headwear?
  POSITIVE_RATINGS.include? headwear
end

#joyObject

Joy likelihood rating. Possible values are VERY_UNLIKELY, UNLIKELY, POSSIBLE, LIKELY, and VERY_LIKELY.



1358
1359
1360
# File 'lib/google/cloud/vision/annotation/face.rb', line 1358

def joy
  @gapi.joy_likelihood
end

#joy?Boolean

Joy likelihood. Returns true if #joy is POSSIBLE, LIKELY, or VERY_LIKELY.

Returns:

  • (Boolean)


1368
1369
1370
# File 'lib/google/cloud/vision/annotation/face.rb', line 1368

def joy?
  POSITIVE_RATINGS.include? joy
end

#sorrowObject

Sorrow likelihood rating. Possible values are VERY_UNLIKELY, UNLIKELY, POSSIBLE, LIKELY, and VERY_LIKELY.



1375
1376
1377
# File 'lib/google/cloud/vision/annotation/face.rb', line 1375

def sorrow
  @gapi.sorrow_likelihood
end

#sorrow?Boolean

Sorrow likelihood. Returns true if #sorrow is POSSIBLE, LIKELY, or VERY_LIKELY.

Returns:

  • (Boolean)


1385
1386
1387
# File 'lib/google/cloud/vision/annotation/face.rb', line 1385

def sorrow?
  POSITIVE_RATINGS.include? sorrow
end

#surpriseObject

Surprise likelihood rating. Possible values are VERY_UNLIKELY, UNLIKELY, POSSIBLE, LIKELY, and VERY_LIKELY.



1409
1410
1411
# File 'lib/google/cloud/vision/annotation/face.rb', line 1409

def surprise
  @gapi.surprise_likelihood
end

#surprise?Boolean

Surprise likelihood. Returns true if #surprise is POSSIBLE, LIKELY, or VERY_LIKELY.

Returns:

  • (Boolean)


1419
1420
1421
# File 'lib/google/cloud/vision/annotation/face.rb', line 1419

def surprise?
  POSITIVE_RATINGS.include? surprise
end

#to_hHash

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

Returns:

  • (Hash)


1480
1481
1482
1483
1484
# File 'lib/google/cloud/vision/annotation/face.rb', line 1480

def to_h
  { joy: joy?, sorrow: sorrow?, anger: anger?, surprise: surprise?,
    under_exposed: under_exposed?, blurred: blurred?,
    headwear: headwear? }
end

#under_exposedObject

Under Exposed likelihood rating. Possible values are VERY_UNLIKELY, UNLIKELY, POSSIBLE, LIKELY, and VERY_LIKELY.



1427
1428
1429
# File 'lib/google/cloud/vision/annotation/face.rb', line 1427

def under_exposed
  @gapi.under_exposed_likelihood
end

#under_exposed?Boolean

Under Exposed likelihood. Returns true if #under_exposed is POSSIBLE, LIKELY, or VERY_LIKELY.

Returns:

  • (Boolean)


1437
1438
1439
# File 'lib/google/cloud/vision/annotation/face.rb', line 1437

def under_exposed?
  POSITIVE_RATINGS.include? under_exposed
end