From 80210f267fd8228cf4f6bbbdbc75059da4f66f6b Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Wed, 5 Oct 2016 17:12:25 -0400 Subject: [PATCH] Projection bug fix. --- gui/OpenFaceDemo/MainWindow.xaml.cs | 6 ++-- lib/local/CppInerop/FaceAnalyserInterop.h | 34 +++++++++++++++-------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/gui/OpenFaceDemo/MainWindow.xaml.cs b/gui/OpenFaceDemo/MainWindow.xaml.cs index ca06cea..38cea10 100644 --- a/gui/OpenFaceDemo/MainWindow.xaml.cs +++ b/gui/OpenFaceDemo/MainWindow.xaml.cs @@ -293,8 +293,8 @@ namespace OpenFaceDemo double nose_wrinkle = au_regs["AU09"] / 4.0 + 0.05; Dictionary smileDict = new Dictionary(); - smileDict[0] = 0.5 * smile_cumm + 0.5 * smile; - smileDict[1] = 0.5 * frown_cumm + 0.5 * frown; + smileDict[0] = 0.6 * smile_cumm + 0.4 * smile; + smileDict[1] = 0.6 * frown_cumm + 0.4 * frown; smilePlot.AddDataPoint(new DataPoint() { Time = CurrentTime, values = smileDict, Confidence = confidence }); Dictionary browDict = new Dictionary(); @@ -466,6 +466,8 @@ namespace OpenFaceDemo } face_analyser.Dispose(); + clnf_model.Dispose(); + this.Close(); } } diff --git a/lib/local/CppInerop/FaceAnalyserInterop.h b/lib/local/CppInerop/FaceAnalyserInterop.h index 8aa4e38..84531df 100644 --- a/lib/local/CppInerop/FaceAnalyserInterop.h +++ b/lib/local/CppInerop/FaceAnalyserInterop.h @@ -332,24 +332,36 @@ public: cv::Mat_ cameraMat = (cv::Mat_(3, 3) << fx, 0, cx, 0, fy, cy, 0, 0, 0); - vector points_left; - points_left.push_back(cv::Point3d(*pupil_left)); - points_left.push_back(cv::Point3d(*pupil_left + *gazeDirection0*40.0)); + vector points_left; + points_left.push_back(cv::Point3f(*pupil_left)); + points_left.push_back(cv::Point3f(*pupil_left + *gazeDirection0*40.0)); - vector points_right; - points_right.push_back(cv::Point3d(*pupil_right)); - points_right.push_back(cv::Point3d(*pupil_right + *gazeDirection1*40.0)); + vector points_right; + points_right.push_back(cv::Point3f(*pupil_right)); + points_right.push_back(cv::Point3f(*pupil_right + *gazeDirection1*40.0)); + // Perform manual projection of points vector imagePoints_left; - projectPoints(points_left, cv::Mat::eye(3, 3, cv::DataType::type), cv::Mat::zeros(1, 3, cv::DataType::type), cameraMat, cv::Mat::zeros(4, 1, cv::DataType::type), imagePoints_left); - + for (int i = 0; i < points_left.size(); ++i) + { + double x = points_left[i].x * fx / points_left[i].z + cx; + double y = points_left[i].y * fy / points_left[i].z + cy; + imagePoints_left.push_back(cv::Point2d(x, y)); + + } + vector imagePoints_right; - projectPoints(points_right, cv::Mat::eye(3, 3, cv::DataType::type), cv::Mat::zeros(1, 3, cv::DataType::type), cameraMat, cv::Mat::zeros(4, 1, cv::DataType::type), imagePoints_right); - + for (int i = 0; i < points_right.size(); ++i) + { + double x = points_right[i].x * fx / points_right[i].z + cx; + double y = points_right[i].y * fy / points_right[i].z + cy; + imagePoints_right.push_back(cv::Point2d(x, y)); + + } + auto lines = gcnew System::Collections::Generic::List^>(); lines->Add(gcnew System::Tuple(System::Windows::Point(imagePoints_left[0].x, imagePoints_left[0].y), System::Windows::Point(imagePoints_left[1].x, imagePoints_left[1].y))); lines->Add(gcnew System::Tuple(System::Windows::Point(imagePoints_right[0].x, imagePoints_right[0].y), System::Windows::Point(imagePoints_right[1].x, imagePoints_right[1].y))); - return lines; }