private void UpdateUI(Bitmap bitmap) { this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { // Display the color image if (bitmap != null) { imgColorStream.Source = ConvertBitmap.BitmapToBitmapSource(bitmap); } // Update UI elements lblNumFacesDetected.Content = String.Format("Faces Detected: {0}", numFacesDetected); lblUserId.Content = String.Format("User ID: {0}", userId); lblDatabaseState.Content = String.Format("Database: {0}", dbState); // Change picture border color depending on if user is in camera view if (numFacesDetected > 0) { bdrPictureBorder.BorderBrush = System.Windows.Media.Brushes.LightGreen; } else { bdrPictureBorder.BorderBrush = System.Windows.Media.Brushes.Red; } // Show or hide face marker if ((numFacesDetected > 0) && (chkShowFaceMarker.IsChecked == true)) { // Show face marker rectFaceMarker.Height = faceRectangleHeight; rectFaceMarker.Width = faceRectangleWidth; Canvas.SetLeft(rectFaceMarker, faceRectangleX); Canvas.SetTop(rectFaceMarker, faceRectangleY); rectFaceMarker.Visibility = Visibility.Visible; // Show floating ID label lblFloatingId.Content = String.Format("User ID: {0}", userId); Canvas.SetLeft(lblFloatingId, faceRectangleX); Canvas.SetTop(lblFloatingId, faceRectangleY - 20); lblFloatingId.Visibility = Visibility.Visible; } else { // Hide the face marker and floating ID label rectFaceMarker.Visibility = Visibility.Hidden; lblFloatingId.Visibility = Visibility.Hidden; } })); // Release resources bitmap.Dispose(); }
private void UpdateUI(Bitmap bitmap) { this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { // Display the color image if (bitmap != null) { imgColorStream.Source = ConvertBitmap.BitmapToBitmapSource(bitmap); } // Update UI elements lblNumFacesDetected.Content = String.Format("Faces Detected: {0}", numFacesDetected); lblUserId.Content = String.Format("User ID: {0}", userId); lblDatabaseState.Content = String.Format("Database: {0}", dbState); lblLooksForward.Content = string.Format("Looks forward: {0}", looksForward); lblSmile.Content = string.Format("smiling:{0}", smile); lblEyesUp.Content = string.Format("Eyes Up: {0}", eyeIsUp); lblEyesDown.Content = string.Format("Eyes Down: {0}", eyeIsDown); lblEyesTurnLeft.Content = string.Format("Eyes turn left:{0}", eyesTurnLeft); lblEyesTurnRight.Content = string.Format("Eyes turn right:{0}", eyesTurnRight); //lblExpressionThreshold.Content = string.Format("Eyes UP W threshold:{0}", eyeIsUP); lblHeadTiltLeft.Content = string.Format("Head Tilted Left:{0}", headTiltLeft); lblHeadTiltRight.Content = string.Format("Head Tilted Right:{0}", headTiltRight); //lblHeadThreshold.Content = string.Format("Head Tilted Left:{0}", headTiltLeftThreshold); lblHeadUp.Content = string.Format("Head Up:{0}", headUp); lblHeadDown.Content = string.Format("Head Down:{0}", headDown); lblHeadTurnedLeft.Content = string.Format("Head Turned Left:{0}", headTurnLeft); lblHeadTurnedRight.Content = string.Format("Head Turned Right:{0}", headTurnRight); lblYaw.Content = string.Format("Yaw: {0}", yaw); lblPitch.Content = string.Format("Pitch: {0}", pitch); lblRoll.Content = string.Format("Roll: {0}", roll); // Change picture border color depending on if user is in camera view if (numFacesDetected > 0) { bdrPictureBorder.BorderBrush = System.Windows.Media.Brushes.LightGreen; } else { bdrPictureBorder.BorderBrush = System.Windows.Media.Brushes.Red; } // Show or hide face marker if ((numFacesDetected > 0) && (chkShowFaceMarker.IsChecked == true)) { // Show face marker rectFaceMarker.Height = faceRectangleHeight; rectFaceMarker.Width = faceRectangleWidth; Canvas.SetLeft(rectFaceMarker, faceRectangleX); Canvas.SetTop(rectFaceMarker, faceRectangleY); rectFaceMarker.Visibility = Visibility.Visible; // Show floating ID label lblFloatingId.Content = String.Format("User ID: {0}", userId); Canvas.SetLeft(lblFloatingId, faceRectangleX); Canvas.SetTop(lblFloatingId, faceRectangleY - 20); lblFloatingId.Visibility = Visibility.Visible; } else { // Hide the face marker and floating ID label rectFaceMarker.Visibility = Visibility.Hidden; lblFloatingId.Visibility = Visibility.Hidden; } })); // Release resources bitmap.Dispose(); }