Reporting a gaze angle that makes more sense.

This commit is contained in:
Tadas Baltrusaitis 2017-10-22 10:03:23 +01:00
parent f6f0d6201c
commit 4b85fe21ac
5 changed files with 11 additions and 18 deletions

View file

@ -496,7 +496,7 @@ int main (int argc, char **argv)
{
GazeAnalysis::EstimateGaze(face_model, gazeDirection0, fx, fy, cx, cy, true);
GazeAnalysis::EstimateGaze(face_model, gazeDirection1, fx, fy, cx, cy, false);
gazeAngle = GazeAnalysis::GetGazeAngle(gazeDirection0, gazeDirection1, pose_estimate);
gazeAngle = GazeAnalysis::GetGazeAngle(gazeDirection0, gazeDirection1);
}
// Do face alignment

View file

@ -222,7 +222,7 @@ namespace OpenFaceOffline
}
if (output_pose)
output_features_file.Write(String.Format(", {0:F3}, {1:F3}, {2:F3}, {3:F3}, {4:F3}, {5:F3}", pose[0], pose[1], pose[2], pose[3], pose[4], pose[5]));
output_features_file.Write(String.Format(", {0:F4}, {1:F4}, {2:F4}, {3:F4}, {4:F4}, {5:F4}", pose[0], pose[1], pose[2], pose[3], pose[4], pose[5]));
if (output_2D_landmarks)
{

View file

@ -109,10 +109,8 @@ namespace GazeAnalyser_Interop {
// Estimate the gaze angle WRT to head pose here
System::Collections::Generic::List<double>^ pose_list = gcnew System::Collections::Generic::List<double>();
clnf->GetPose(pose_list, fx, fy, cx, cy);
cv::Vec6d pose(pose_list[0], pose_list[1], pose_list[2], pose_list[3], pose_list[4], pose_list[5]);
*gazeAngle = GazeAnalysis::GetGazeAngle(*gazeDirection0, *gazeDirection1, pose);
*gazeAngle = GazeAnalysis::GetGazeAngle(*gazeDirection0, *gazeDirection1);
// Grab pupil locations
int part_left = -1;

View file

@ -45,8 +45,8 @@ namespace GazeAnalysis
void EstimateGaze(const LandmarkDetector::CLNF& clnf_model, cv::Point3f& gaze_absolute, float fx, float fy, float cx, float cy, bool left_eye);
void DrawGaze(cv::Mat img, const LandmarkDetector::CLNF& clnf_model, cv::Point3f gazeVecAxisLeft, cv::Point3f gazeVecAxisRight, float fx, float fy, float cx, float cy);
// Getting the gaze angle in radians with respect to head pose (need to call EstimateGaze first)
cv::Vec2d GetGazeAngle(cv::Point3f& gaze_vector_1, cv::Point3f& gaze_vector_2, cv::Vec6d head_pose);
// Getting the gaze angle in radians with respect to the world coordinates (camera plane), when looking ahead straight at camera plane the gaze angle will be (0,0)
cv::Vec2d GetGazeAngle(cv::Point3f& gaze_vector_1, cv::Point3f& gaze_vector_2);
// Some utilities
cv::Point3f GetPupilPosition(cv::Mat_<double> eyeLdmks3d);

View file

@ -136,18 +136,13 @@ void GazeAnalysis::EstimateGaze(const LandmarkDetector::CLNF& clnf_model, cv::Po
gaze_absolute = gazeVecAxis / norm(gazeVecAxis);
}
cv::Vec2d GazeAnalysis::GetGazeAngle(cv::Point3f& gaze_vector_1, cv::Point3f& gaze_vector_2, cv::Vec6d head_pose)
cv::Vec2d GazeAnalysis::GetGazeAngle(cv::Point3f& gaze_vector_1, cv::Point3f& gaze_vector_2)
{
cv::Vec3d eulerAngles(head_pose(3), head_pose(4), head_pose(5));
cv::Matx33d rotMat = LandmarkDetector::Euler2RotationMatrix(eulerAngles);
cv::Point3f gaze_point = (gaze_vector_1 + gaze_vector_2) / 2;
cv::Vec3d gaze(gaze_point.x, gaze_point.y, gaze_point.z);
cv::Point3f gaze_vector = (gaze_vector_1 + gaze_vector_2) / 2;
gaze = rotMat * gaze;
double x_angle = atan2(gaze[0], -gaze[2]);
double y_angle = atan2(gaze[1], -gaze[2]);
double x_angle = atan2(gaze_vector.x, -gaze_vector.z);
double y_angle = atan2(gaze_vector.y, -gaze_vector.z);
return cv::Vec2d(x_angle, y_angle);