diff --git a/gui/OpenFaceOffline/MainWindow.xaml.cs b/gui/OpenFaceOffline/MainWindow.xaml.cs index 92fa112..3ffa39b 100644 --- a/gui/OpenFaceOffline/MainWindow.xaml.cs +++ b/gui/OpenFaceOffline/MainWindow.xaml.cs @@ -136,7 +136,7 @@ namespace OpenFaceOffline public bool DynamicAUModels { get; set; } = true; // Camera calibration parameters - public double fx = -1, fy = -1, cx = -1, cy = -1; + public float fx = -1, fy = -1, cx = -1, cy = -1; bool estimate_camera_parameters = true; public MainWindow() @@ -343,10 +343,10 @@ namespace OpenFaceOffline // If the camera calibration parameters are not set (indicated by -1), guesstimate them if(estimate_camera_parameters || fx == -1 || fy == -1 || cx == -1 || cy == -1) { - fx = 500.0 * (capture.width / 640.0); - fy = 500.0 * (capture.height / 480.0); + fx = 500.0f * (capture.width / 640.0f); + fy = 500.0f * (capture.height / 480.0f); - fx = (fx + fy) / 2.0; + fx = (fx + fy) / 2.0f; fy = fx; cx = capture.width / 2f; @@ -472,7 +472,7 @@ namespace OpenFaceOffline } - private void VisualizeFeatures(RawImage frame, Visualizer visualizer, List> landmarks, bool new_image, double fx, double fy, double cx, double cy, double progress) + private void VisualizeFeatures(RawImage frame, Visualizer visualizer, List> landmarks, bool new_image, float fx, float fy, float cx, float cy, double progress) { List> lines = null; @@ -494,6 +494,10 @@ namespace OpenFaceOffline double scale = 0; // Helps with recording and showing the visualizations + if(new_image) + { + visualizer.SetImage(frame, fx, fy, cx, cy); + } visualizer.SetObservationHOG(face_analyser.GetLatestHOGFeature(), face_analyser.GetHOGRows(), face_analyser.GetHOGCols()); visualizer.SetObservationLandmarks(landmarks, confidence); // Set confidence to high to make sure we always visualize visualizer.SetObservationPose(pose, confidence); @@ -503,11 +507,11 @@ namespace OpenFaceOffline { eye_landmarks = clnf_model.CalculateVisibleEyeLandmarks(); - lines = clnf_model.CalculateBox((float)fx, (float)fy, (float)cx, (float)cy); + lines = clnf_model.CalculateBox(fx, fy, cx, cy); scale = clnf_model.GetRigidParams()[0]; - gaze_lines = gaze_analyser.CalculateGazeLines(scale, (float)fx, (float)fy, (float)cx, (float)cy); + gaze_lines = gaze_analyser.CalculateGazeLines(scale, fx, fy, cx, cy); gaze_angle = gaze_analyser.GetGazeAngle(); } diff --git a/gui/OpenFaceOffline/UI_items/CameraParametersEntry.xaml.cs b/gui/OpenFaceOffline/UI_items/CameraParametersEntry.xaml.cs index 9061efe..7bf0db7 100644 --- a/gui/OpenFaceOffline/UI_items/CameraParametersEntry.xaml.cs +++ b/gui/OpenFaceOffline/UI_items/CameraParametersEntry.xaml.cs @@ -78,7 +78,7 @@ namespace OpenFaceOffline /// public partial class CameraParametersEntry : Window { - public CameraParametersEntry(double fx, double fy, double cx, double cy) + public CameraParametersEntry(float fx, float fy, float cx, float cy) { InitializeComponent(); this.KeyDown += new KeyEventHandler(TextEntry_KeyDown); @@ -122,26 +122,26 @@ namespace OpenFaceOffline } } - private double fx = -1, fy = -1, cx = -1, cy = -1; + private float fx = -1, fy = -1, cx = -1, cy = -1; public bool IsAutomatic { get { return automaticCheckBox.IsChecked == true; } } - public double Fx + public float Fx { get { return automaticCheckBox.IsChecked == true ? -1 : fx; } } - public double Fy + public float Fy { get { return automaticCheckBox.IsChecked == true ? -1 : fy; } } - public double Cx + public float Cx { get { return automaticCheckBox.IsChecked == true ? -1 : cx; } } - public double Cy + public float Cy { get { return automaticCheckBox.IsChecked == true ? -1 : cy; } } @@ -169,10 +169,10 @@ namespace OpenFaceOffline { try { - double fx_n = Double.Parse(fxTextBox.Text); - double fy_n = Double.Parse(fyTextBox.Text); - double cx_n = Double.Parse(cxTextBox.Text); - double cy_n = Double.Parse(cyTextBox.Text); + float fx_n = (float)Double.Parse(fxTextBox.Text); + float fy_n = (float)Double.Parse(fyTextBox.Text); + float cx_n = (float)Double.Parse(cxTextBox.Text); + float cy_n = (float)Double.Parse(cyTextBox.Text); if (fx_n > 0 && fy_n > 0 && cx_n > 0 && cy_n > 0) { diff --git a/lib/local/CppInerop/VisualizerInterop.h b/lib/local/CppInerop/VisualizerInterop.h index 1c8033c..512d4a5 100644 --- a/lib/local/CppInerop/VisualizerInterop.h +++ b/lib/local/CppInerop/VisualizerInterop.h @@ -113,6 +113,11 @@ namespace UtilitiesOF { m_visualizer->SetObservationLandmarks(landmarks_2D_mat, confidence); } + void SetImage(OpenCVWrappers::RawImage^ canvas, float fx, float fy, float cx, float cy) + { + m_visualizer->SetImage(canvas->Mat, fx, fy, cx, cy); + } + OpenCVWrappers::RawImage^ GetHOGVis() { OpenCVWrappers::RawImage^ hog_image = gcnew OpenCVWrappers::RawImage(m_visualizer->GetHOGVis());