Estimate a smoothed height of the face from its 2D sights.
Module CuedSpeech.wherecue
Class sppasFaceHeight
Description
Public functions
eval_height
Estimate the size coefficient of the given face using facial landmarks.
This method computes a face size coefficient based on three facial sights: points 19 and 24 (which define a segment across the face), and point 8 (typically the chin).
It calculates the midpoint between points 19 and 24, then returns the Euclidean distance from this midpoint to point 8. This value is useful for normalizing hand size relative to face size in images.
Parameters
- face_sights: (sppasSights) The facial landmarks (68 points expected).
Returns
- (float) A coefficient representing the size of the given face.
Raises
- sppasTypeError: Invalid given face sights argument
- sppasError: Invalid number of given face sights
View Source
@staticmethod
def eval_height(face_sights):
"""Estimate the size coefficient of the given face using facial landmarks.
This method computes a face size coefficient based on three facial sights:
points 19 and 24 (which define a segment across the face), and point 8
(typically the chin).
It calculates the midpoint between points 19 and 24, then returns the
Euclidean distance from this midpoint to point 8. This value is useful
for normalizing hand size relative to face size in images.
:param face_sights: (sppasSights) The facial landmarks (68 points expected).
:return: (float) A coefficient representing the size of the given face.
:raises: sppasTypeError: Invalid given face sights argument
:raises: sppasError: Invalid number of given face sights
"""
if isinstance(face_sights, sppasSights) is False:
raise sppasTypeError(type(face_sights), 'sppasSights')
if len(face_sights) != 68:
raise sppasError(f'Invalid number of sights. Expected 68. Got {len(face_sights)} instead')
_dx = abs(face_sights.x(19) - face_sights.x(24))
_dy = abs(face_sights.y(19) - face_sights.y(24))
_x = float(face_sights.x(19)) + _dx / 2.0
_y = float(face_sights.y(19)) + _dy / 2.0
return euclidian((_x, _y), (face_sights.x(8), face_sights.y(8)))
