Reporting a gaze angle that makes more sense.
This commit is contained in:
parent
f6f0d6201c
commit
4b85fe21ac
5 changed files with 11 additions and 18 deletions
|
@ -496,7 +496,7 @@ int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
GazeAnalysis::EstimateGaze(face_model, gazeDirection0, fx, fy, cx, cy, true);
|
GazeAnalysis::EstimateGaze(face_model, gazeDirection0, fx, fy, cx, cy, true);
|
||||||
GazeAnalysis::EstimateGaze(face_model, gazeDirection1, fx, fy, cx, cy, false);
|
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
|
// Do face alignment
|
||||||
|
|
|
@ -222,7 +222,7 @@ namespace OpenFaceOffline
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output_pose)
|
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)
|
if (output_2D_landmarks)
|
||||||
{
|
{
|
||||||
|
|
|
@ -109,10 +109,8 @@ namespace GazeAnalyser_Interop {
|
||||||
|
|
||||||
// Estimate the gaze angle WRT to head pose here
|
// Estimate the gaze angle WRT to head pose here
|
||||||
System::Collections::Generic::List<double>^ pose_list = gcnew System::Collections::Generic::List<double>();
|
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
|
// Grab pupil locations
|
||||||
int part_left = -1;
|
int part_left = -1;
|
||||||
|
|
|
@ -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 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);
|
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)
|
// 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, cv::Vec6d head_pose);
|
cv::Vec2d GetGazeAngle(cv::Point3f& gaze_vector_1, cv::Point3f& gaze_vector_2);
|
||||||
|
|
||||||
// Some utilities
|
// Some utilities
|
||||||
cv::Point3f GetPupilPosition(cv::Mat_<double> eyeLdmks3d);
|
cv::Point3f GetPupilPosition(cv::Mat_<double> eyeLdmks3d);
|
||||||
|
|
|
@ -136,18 +136,13 @@ void GazeAnalysis::EstimateGaze(const LandmarkDetector::CLNF& clnf_model, cv::Po
|
||||||
gaze_absolute = gazeVecAxis / norm(gazeVecAxis);
|
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::Point3f gaze_vector = (gaze_vector_1 + gaze_vector_2) / 2;
|
||||||
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);
|
|
||||||
|
|
||||||
gaze = rotMat * gaze;
|
double x_angle = atan2(gaze_vector.x, -gaze_vector.z);
|
||||||
|
double y_angle = atan2(gaze_vector.y, -gaze_vector.z);
|
||||||
double x_angle = atan2(gaze[0], -gaze[2]);
|
|
||||||
double y_angle = atan2(gaze[1], -gaze[2]);
|
|
||||||
|
|
||||||
return cv::Vec2d(x_angle, y_angle);
|
return cv::Vec2d(x_angle, y_angle);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue