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/vision"

vision = Google::Cloud::Vision.new

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 =
%i[POSSIBLE LIKELY VERY_LIKELY].freeze

Instance Method Summary collapse

Instance Method Details

#angerObject

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



1377
1378
1379
# File 'lib/google/cloud/vision/annotation/face.rb', line 1377

def anger
  @grpc.anger_likelihood
end

#anger?Boolean

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

Returns:

  • (Boolean)


1387
1388
1389
# File 'lib/google/cloud/vision/annotation/face.rb', line 1387

def anger?
  POSITIVE_RATINGS.include? anger
end

#blurredObject

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



1429
1430
1431
# File 'lib/google/cloud/vision/annotation/face.rb', line 1429

def blurred
  @grpc.blurred_likelihood
end

#blurred?Boolean

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

Returns:

  • (Boolean)


1439
1440
1441
# File 'lib/google/cloud/vision/annotation/face.rb', line 1439

def blurred?
  POSITIVE_RATINGS.include? blurred
end

#headwearObject

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



1446
1447
1448
# File 'lib/google/cloud/vision/annotation/face.rb', line 1446

def headwear
  @grpc.headwear_likelihood
end

#headwear?Boolean

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

Returns:

  • (Boolean)


1456
1457
1458
# File 'lib/google/cloud/vision/annotation/face.rb', line 1456

def headwear?
  POSITIVE_RATINGS.include? headwear
end

#joyObject

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



1343
1344
1345
# File 'lib/google/cloud/vision/annotation/face.rb', line 1343

def joy
  @grpc.joy_likelihood
end

#joy?Boolean

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

Returns:

  • (Boolean)


1353
1354
1355
# File 'lib/google/cloud/vision/annotation/face.rb', line 1353

def joy?
  POSITIVE_RATINGS.include? joy
end

#sorrowObject

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



1360
1361
1362
# File 'lib/google/cloud/vision/annotation/face.rb', line 1360

def sorrow
  @grpc.sorrow_likelihood
end

#sorrow?Boolean

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

Returns:

  • (Boolean)


1370
1371
1372
# File 'lib/google/cloud/vision/annotation/face.rb', line 1370

def sorrow?
  POSITIVE_RATINGS.include? sorrow
end

#surpriseObject

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



1394
1395
1396
# File 'lib/google/cloud/vision/annotation/face.rb', line 1394

def surprise
  @grpc.surprise_likelihood
end

#surprise?Boolean

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

Returns:

  • (Boolean)


1404
1405
1406
# File 'lib/google/cloud/vision/annotation/face.rb', line 1404

def surprise?
  POSITIVE_RATINGS.include? surprise
end

#to_hHash

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

Returns:

  • (Hash)


1465
1466
1467
1468
1469
# File 'lib/google/cloud/vision/annotation/face.rb', line 1465

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.



1412
1413
1414
# File 'lib/google/cloud/vision/annotation/face.rb', line 1412

def under_exposed
  @grpc.under_exposed_likelihood
end

#under_exposed?Boolean

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

Returns:

  • (Boolean)


1422
1423
1424
# File 'lib/google/cloud/vision/annotation/face.rb', line 1422

def under_exposed?
  POSITIVE_RATINGS.include? under_exposed
end