int trackedSkeletonsCount; // The number of skeletons that are recognized #endregion Fields #region Constructors public MainWindow() { box1 = new Box(); box1.Left = canvasWidth / 2 - box1.BoxRect.Width / 2; box1.Top = canvasHeight / 2 - box1.BoxRect.Height / 2; prevBox1 = new Box(); prevBox1.Left = canvasWidth / 2 - prevBox1.BoxRect.Width / 2; prevBox1.Top = canvasHeight / 2 - prevBox1.BoxRect.Height / 2; rightCircle = new Ellipse(); rightCircle.Stroke = System.Windows.Media.Brushes.MediumBlue; rightCircle.Fill = System.Windows.Media.Brushes.Black; rightCircle.Opacity = 0.8; rightCircle.StrokeThickness = 5; rightCircle.Width = 20f; rightCircle.Height = 20f; leftCircle = new Ellipse(); leftCircle.Stroke = System.Windows.Media.Brushes.Maroon; leftCircle.Fill = System.Windows.Media.Brushes.Black; leftCircle.Opacity = 0.8; leftCircle.StrokeThickness = 5; leftCircle.Width = 20f; leftCircle.Height = 20f; InitializeComponent(); setupKinect(); }
// A method that returns a copy of this Box public Box Clone() { Box clone = new Box(); clone.BoxRect = new Rectangle(); clone.BoxRect.Stroke = System.Windows.Media.Brushes.FloralWhite; clone.BoxRect.Fill = color; clone.BoxRect.Opacity = 0.8; clone.BoxRect.Width = this.BoxRect.Width; clone.BoxRect.Height = this.BoxRect.Height; clone.BoxRect.MinWidth = 20f; clone.BoxRect.MinHeight = 20f; clone.BoxRect.StrokeThickness = 3; clone.color = this.color; clone.Left = this.Left; clone.Top = this.Top; //clone.isMoving = false; //clone.isStretching = false; return clone; }
void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { double confidence = 0.85; if (e.Result.Text.ToLower() == "transport" && e.Result.Confidence >= confidence) { labelSpeech.Content = "Recognized \"transport\" with " + (100 * e.Result.Confidence) + "% confidence"; if (phase == "neutral") { transportPhase(); } } else if (e.Result.Text.ToLower() == "stretch" && e.Result.Confidence >= confidence) { labelSpeech.Content = "Recognized \"stretch\" with " + (100 * e.Result.Confidence) + "% confidence"; if (phase == "neutral") { stretchPhase(); } } else if (e.Result.Text.ToLower() == "scale" && e.Result.Confidence >= confidence) { labelSpeech.Content = "Recognized \"scale\" with " + (100 * e.Result.Confidence) + "% confidence"; if (phase == "neutral") { scalePhase(); } } else if (e.Result.Text.ToLower() == "color" && e.Result.Confidence >= confidence) { labelSpeech.Content = "Recognized \"color\" with " + (100 * e.Result.Confidence) + "% confidence"; if (phase == "neutral") { colorPhase(); } } else if (phase == "color" && e.Result.Text.ToLower() == "white" && e.Result.Confidence >= confidence) { labelSpeech.Content = "Recognized \"white\" with " + (100 * e.Result.Confidence) + "% confidence"; box1.Color = System.Windows.Media.Brushes.White; } else if (phase == "color" && e.Result.Text.ToLower() == "black" && e.Result.Confidence >= confidence) { labelSpeech.Content = "Recognized \"black\" with " + (100 * e.Result.Confidence) + "% confidence"; box1.Color = System.Windows.Media.Brushes.Black; } else if (phase == "color" && e.Result.Text.ToLower() == "red" && e.Result.Confidence >= confidence) { labelSpeech.Content = "Recognized \"red\" with " + (100 * e.Result.Confidence) + "% confidence"; box1.Color = System.Windows.Media.Brushes.Red; } else if (phase == "color" && e.Result.Text.ToLower() == "green" && e.Result.Confidence >= confidence) { labelSpeech.Content = "Recognized \"green\" with " + (100 * e.Result.Confidence) + "% confidence"; box1.Color = System.Windows.Media.Brushes.Green; } else if (phase == "color" && e.Result.Text.ToLower() == "blue" && e.Result.Confidence >= confidence) { labelSpeech.Content = "Recognized \"blue\" with " + (100 * e.Result.Confidence) + "% confidence"; box1.Color = System.Windows.Media.Brushes.DodgerBlue; } else if (e.Result.Text.ToLower() == "stop" && e.Result.Confidence >= confidence) { labelSpeech.Content = "Recognized \"stop\" with " + (100 * e.Result.Confidence) + "% confidence"; if (phase != "netrual") { phase = "neutral"; leftCircle.Fill = System.Windows.Media.Brushes.Black; rightCircle.Fill = System.Windows.Media.Brushes.Black; box1.isMoving = box1.isStretching = box1.isScaling = false; labelTransport.Opacity = 1; labelStretch.Opacity = 1; labelColor.Opacity = 1; labelScale.Opacity = 1; labelColorWhite.Opacity = 0; labelColorBlack.Opacity = 0; labelColorRed.Opacity = 0; labelColorGreen.Opacity = 0; labelColorBlue.Opacity = 0; labelReset.Opacity = 1; labelUndo.Opacity = 1; labelTerminate.Opacity = 1; } } else if (e.Result.Text.ToLower() == "undo" && e.Result.Confidence >= confidence) { labelSpeech.Content = "Recognized \"undo\" with " + (100 * e.Result.Confidence) + "% confidence"; if (phase == "neutral") { box1 = prevBox1.Clone(); } } else if (e.Result.Text.ToLower() == "reset" && e.Result.Confidence >= confidence) { labelSpeech.Content = "Recognized \"reset\" with " + (100 * e.Result.Confidence) + "% confidence"; if (phase == "neutral") { box1 = new Box(); box1.Left = canvasWidth / 2 - box1.BoxRect.Width / 2; box1.Top = canvasHeight / 2 - box1.BoxRect.Height / 2; } } else if (e.Result.Text.ToLower() == "terminate" && e.Result.Confidence >= confidence + 0.05) { if (phase == "neutral") { this.Close(); } } }