Some bug fixes.

This commit is contained in:
Tadas Baltrusaitis 2018-01-21 10:08:24 +00:00
parent 852ffd7cb0
commit 97ef5087e3
3 changed files with 26 additions and 17 deletions

View file

@ -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<Tuple<double, double>> landmarks, bool new_image, double fx, double fy, double cx, double cy, double progress)
private void VisualizeFeatures(RawImage frame, Visualizer visualizer, List<Tuple<double, double>> landmarks, bool new_image, float fx, float fy, float cx, float cy, double progress)
{
List<Tuple<Point, Point>> 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();
}

View file

@ -78,7 +78,7 @@ namespace OpenFaceOffline
/// </summary>
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)
{

View file

@ -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());