private void UpdateHead(FrameworkElement face, Body body, FaceFrameResult faceResult, Point point) { face.Visibility = Visibility.Visible; bool isLeftEyeClosed = false, isRightEyeClosed = false, isHappy = false; // If face tracking working if(faceResult != null) { // Mouth isHappy = faceResult.FaceProperties[FaceProperty.Happy] == DetectionResult.Yes; // Eyes isLeftEyeClosed = faceResult.FaceProperties[FaceProperty.LeftEyeClosed] == DetectionResult.Yes ? true : false; isRightEyeClosed = faceResult.FaceProperties[FaceProperty.RightEyeClosed] == DetectionResult.Yes ? true : false; } body.UpdateMouth(isHappy); body.UpdateEye(!isLeftEyeClosed, true); body.UpdateEye(!isRightEyeClosed, false); // Position Head double borderLeft = point.X - face.Width / 2; double borderRight = point.Y - face.Height / 2; if (!Double.IsInfinity(point.X) && !Double.IsInfinity(point.Y)) { Canvas.SetLeft(face, borderLeft); Canvas.SetTop(face, borderRight); } }