public kinectApp(Canvas c, Canvas top, Label l, featureExtractor featExtractor) { //update the feature globalVars.kinectOn = false; contextCounter = 0; this.kinect = null; this.fExtractor = featExtractor; this.features = new startFeatures(); globalVars.gFeature = features; //globalVars.mFeature = this.file = new fileWriter(null); this.canvas = c; this.topCanvas = top; this.spinePos = l; //Runtime.Kinects. if (Runtime.Kinects.Count == 0) { isKinectRunning = false; } else if (Runtime.Kinects.Count > 0 ) { isKinectRunning = true; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { learnOn = false; detectOn = true; recordOn = false; settingsOn = false; //label1.Content = "ahhaaaha"; //labelFrame.Content = "frame"; globalVars.screenH = ((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualHeight; globalVars.screenW = ((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualWidth; globalVars.a1 = labelFrame; //globalVars.a2 = wDistLabel; globalVars.error = AnnError; globalVars.annIter = iterCount; globalVars.saveANNbutn = saveANNbutn; //globalVars.jerkLabel = jerkLabel; globalVars.ValenceOutput = outputLabel; globalVars.ArousalOutput = label14; globalVars.typeOfLearning = 1;//= Convert.ToInt32(typeofann.Text.ToString()); try { globalVars.outputCount = Convert.ToInt32(outputCount.Text.ToString()); } catch{System.Windows.MessageBox.Show("conversion to number failed. Reverting to default value.", "probably your fault.", MessageBoxButton.OK, MessageBoxImage.Exclamation); globalVars.outputCount = 1;} try { globalVars.hiddenCount = Convert.ToInt32(hiddenCount.Text.ToString()); } catch{System.Windows.MessageBox.Show("conversion to number failed. Reverting to default value.", "probably your fault.", MessageBoxButton.OK, MessageBoxImage.Exclamation); globalVars.hiddenCount = 4;} recordCanvas.Visibility = System.Windows.Visibility.Hidden; learnCanvas.Visibility = System.Windows.Visibility.Hidden; settingsCanvas.Visibility = System.Windows.Visibility.Hidden; double a, b, c, d, ef; try { a = Math.Abs(Convert.ToDouble(lThres.Text.ToString())); } catch{System.Windows.MessageBox.Show("conversion to number failed. Reverting to default value.", "probably your fault.", MessageBoxButton.OK, MessageBoxImage.Exclamation); a = 0.005;} try { b = Math.Abs(Convert.ToDouble(uThres.Text.ToString())); } catch{System.Windows.MessageBox.Show("conversion to number failed. Reverting to default value.", "probably your fault.", MessageBoxButton.OK, MessageBoxImage.Exclamation); b = 1;} if (a >= b) { System.Windows.MessageBox.Show("Lower Threshold can not be greater or eqal to Upper Threshold. Reverting back to default Values of 0.005 and 1", "you moron.", MessageBoxButton.OK, MessageBoxImage.Exclamation); lThres.Text = "0.005"; uThres.Text = "1"; a = 0.005; b = 1; } try { c = Math.Abs(Convert.ToDouble(surgeThres.Text.ToString())); } catch{System.Windows.MessageBox.Show("conversion to number failed. Reverting to default value.", "probably your fault.", MessageBoxButton.OK, MessageBoxImage.Exclamation); c = 10;} //ufdelay = update feature delay try { d = Math.Abs(Convert.ToDouble(ufDelay.Text.ToString())); } catch{System.Windows.MessageBox.Show("conversion to number failed. Reverting to default value.", "probably your fault.", MessageBoxButton.OK, MessageBoxImage.Exclamation); d = 0.2;} // gfdelay = get feature delay try { ef = Math.Abs(Convert.ToDouble(gfDelay.Text.ToString())); } catch{System.Windows.MessageBox.Show("conversion to number failed. Reverting to default value.", "probably your fault.", MessageBoxButton.OK, MessageBoxImage.Exclamation); ef = 1;} if (d >= ef) { System.Windows.MessageBox.Show("UpdateFeature delay can not be greater or eqal to EmotionRecognition delay. Reverting back to default Values of 0.2 and 1", "you moron.", MessageBoxButton.OK, MessageBoxImage.Exclamation); lThres.Text = "0.2"; uThres.Text = "1"; d = 0.2; ef = 1; } //initializig feature extractor and passing the update graph. fExtract = new featureExtractor(d, ef, a, b, c, globalVars.chart2); globalVars.fExtract = this.fExtract; //Thread kinAppThrd = new Thread(() => { app = new kinectApp(canvas1, canvas2, label1, image1, fExtract); }); //kinAppThrd.Start(); app = new kinectApp(canvas1, canvas2, label1, fExtract); // delivering wpf control referencess to kinectapp app.poseContextLabel1 = poseContextLabel1; app.poseContextLabel2 = poseContextLabel2; app.poseContextImage = poseContextImage; app.kinectstateLabel = kinectstateLabel; app.refreshKinect = refreshKinect; app.kinectBulb = kinectBulb; //if (globalVars.kinectOn == true) //updateKinectStatusOn(); if (app.isKinectRunning) globalVars.kinectOn = app.initKinect(); else System.Windows.MessageBox.Show("Kinect is not running. Please power on the Kinect and connect the USB connector to your computer.", "Kinect Not running", MessageBoxButton.OK, MessageBoxImage.Error); }