OpenFace – a state-of-the art tool intended for facial landmark detection, head pose estimation, facial action unit recognition, and eye-gaze estimation.
Other
6.71k
stars
1.82k
forks
source link
Gaze Angle is Absolute. How can I calculate it with respect to Camera ? #1050
def calculate_angle_between_vectors(vector1, vector2):
dot_product = sum(a * b for a, b in zip(vector1, vector2))
magnitude1 = math.sqrt(sum(a**2 for a in vector1))
magnitude2 = math.sqrt(sum(b**2 for b in vector2))
cos_theta = dot_product / (magnitude1 * magnitude2)
# Handle edge cases to avoid math domain error
cos_theta = max(min(cos_theta, 1), -1)
# Calculate angles in x and y directions
x_angle_in_radians = math.atan2(vector2[1], vector2[0])
x_angle_in_degrees = math.degrees(x_angle_in_radians)
y_angle_in_radians = math.atan2(vector2[2], vector2[0])
y_angle_in_degrees = math.degrees(y_angle_in_radians)
return x_angle_in_degrees, y_angle_in_degrees
# here eyeball centre is 3d location of eyeball centre and eyeballCentreNormalised is ray from (0,0,0) to eyeballcentre.
eyeballCentreNormalised = eyeballCentre / norm(eyeballCentre);
gaze_absolute = gazeVecAxis / norm(gazeVecAxis);
#Here we calculate the angle between gaze_absolute and the ray from eyeballcentre
x_angle_degrees, y_angle_degrees = calculate_angle_between_vectors(eyeballCentreNormalised, gazeAbsolute)
The Output of this method was:
X-angle: 157.61 degrees
Y-angle: -111.96 degrees
I suppose, these are not correct angles. Kindly guide me how to proceed further on this issue.
Hello Tadas,
Thank you so much for sourcing this useful repository, I have some questions, kindly look into this:
I ran OpenFace for gaze estimation with another face detection model on Columbia Gaze Dataset, Image : 0033_2m_30P_0V_0H
and the results are: Gaze Angle (Degrees): (-18.870744753694947, 7.512340676394768)
These angles are w.r.t. eyeball, how can I calculate w.r.t. camera ?
We tried your approach but could not get correct results : https://github.com/TadasBaltrusaitis/OpenFace/issues/865#issuecomment-619188237
The Output of this method was: X-angle: 157.61 degrees Y-angle: -111.96 degrees
I suppose, these are not correct angles. Kindly guide me how to proceed further on this issue.
Regards, Prashant