private static void addTrackingJoints() { // Adding the joints I want to track SkeletonUtils.addJoint(JointType.ShoulderLeft); SkeletonUtils.addJoint(JointType.ShoulderRight); SkeletonUtils.addJoint(JointType.ElbowLeft); SkeletonUtils.addJoint(JointType.ElbowRight); SkeletonUtils.addJoint(JointType.WristLeft); SkeletonUtils.addJoint(JointType.WristRight); }
public void dataArrived(object data) { Skeleton defaultSkeleton = SkeletonUtils.defaultSkeleton(data); if (defaultSkeleton == null) { return; } SkeletonUtils.redraw(skeletonCanvas, defaultSkeleton, drawingTag, drawingColor); }
private void UnselectBucket(BucketPosition pos) { SkeletonUtils.modifyUI( new ThreadStart(() => { try { boxes[(int)pos].Fill = new SolidColorBrush((getController(pos).getVolume() > 100) ? Colors.Green : Colors.White); progressBars[(int)pos].Value = getController(pos).getVolume(); } catch (Exception) { } })); }
public void dataArrived(object data) { Skeleton skeleton = SkeletonUtils.defaultSkeleton(data); if (skeleton == null) { return; } Color color = analyzer.checkPosition(skeleton); // Use this instead of redraw to make the image that shows the buckets //Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() => // SkeletonUtils.DrawSkeleton(skelcanvas, skeleton, color, "armdsdfanalyzer"))); //SkeletonUtils.redraw(skelcanvas, skeleton, "armdsdfanalyzer", Colors.Cyan); }
public void setUpRecognized() { SkeletonUtils.modifyUI( new ThreadStart(() => { try { voiceControl.Fill = new SolidColorBrush(Colors.Green); } catch (Exception) { } })); if (skeletonClient != null) { skeletonClient.unsubscribeAll(); skeletonClient.subscribe(new SkeletonListener(skeletonCanvas)); recordingStream = new CurrentRecording(); skeletonClient.subscribe(recordingStream); } foreach (BucketPosition pos in Enum.GetValues(typeof(BucketPosition))) { if (getController(pos) != null) { SkeletonUtils.modifyUI( new ThreadStart(() => { try { progressBars[(int)pos].Value = getController(pos).getVolume(); } catch (Exception) { } })); SkeletonUtils.modifyUI( new ThreadStart(() => { try { boxes[(int)pos].Fill = new SolidColorBrush((getController(pos).getVolume() > 100) ? Colors.Green : Colors.White); } catch (Exception) { } })); } } playing = false; }
/// <summary> /// Utility funcion to avoid repetition of this action, remove the previous skeleton and draw the new one. /// </summary> public static void redraw(Canvas canvas, Skeleton actual, string tag, Color color) { modifyUI(new ThreadStart(() => { try { DrawingUtils.deleteElements(canvas, tag); } catch (Exception) { } })); modifyUI(new ThreadStart(() => { try { SkeletonUtils.DrawSkeleton(canvas, actual, color, tag); } catch (Exception) { } })); }
public void dataArrived(object data) { if (recorder.finished()) { if (client != null) { client.unsubscribe(this); Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() => DrawingUtils.deleteElements(skeletonCanvas, tag))); return; } else { recorder.restart(); } } SkeletonUtils.redraw(skeletonCanvas, recorder.next(), tag, color); }
public void selectBucket(BucketPosition pos) { SkeletonUtils.modifyUI( new ThreadStart(() => { try { boxes[(int)pos].Fill = new SolidColorBrush(Colors.Cyan); } catch (Exception) { } })); System.Timers.Timer myTimer = new System.Timers.Timer(); myTimer.Elapsed += delegate { UnselectBucket(pos); }; myTimer.Interval = 1000; // 1s myTimer.Start(); }
public void saveToFile(string filePath) { SkeletonUtils.serialize(skeletons, filePath); }
public void toggleBuckets() { if (bucketsEnabled) { // Deactivate them foreach (BucketPosition pos in Enum.GetValues(typeof(BucketPosition))) { if (allControllers[(int)pos] != null) { SkeletonUtils.modifyUI( new ThreadStart(() => { try { enablers[(int)pos].IsEnabled = false; } catch (Exception) { } })); } } if (leftArmAnalyzer != null) { skeletonClient.unsubscribe(leftArmAnalyzer); } if (rightArmAnalyzer != null) { skeletonClient.unsubscribe(rightArmAnalyzer); } SkeletonUtils.modifyUI( new ThreadStart(() => { try { voiceControl.Fill = new SolidColorBrush(Colors.Orange); } catch (Exception) { } })); bucketsEnabled = false; } else { // Activate them foreach (BucketPosition pos in Enum.GetValues(typeof(BucketPosition))) { if (allControllers[(int)pos] != null) { SkeletonUtils.modifyUI( new ThreadStart(() => { try { enablers[(int)pos].IsEnabled = true; } catch (Exception) { } })); } } if (leftArmAnalyzer != null) { skeletonClient.subscribe(leftArmAnalyzer); } if (rightArmAnalyzer != null) { skeletonClient.subscribe(rightArmAnalyzer); } SkeletonUtils.modifyUI( new ThreadStart(() => { try { voiceControl.Fill = new SolidColorBrush(Colors.Cyan); } catch (Exception) { } })); bucketsEnabled = true; } }
public void startRecognized() { if (playing) { // Will stop playing now playing = false; if (leftArmAnalyzer != null) { skeletonClient.unsubscribe(leftArmAnalyzer); } if (rightArmAnalyzer != null) { skeletonClient.unsubscribe(rightArmAnalyzer); } for (int i = 0; i < movements.Length; i++) { if (movements[i] != null) { skeletonClient.unsubscribe(movements[i]); } } } else { // Will start playing now playing = true; if (bucketsEnabled) { if (leftArmAnalyzer != null) { skeletonClient.subscribe(leftArmAnalyzer); } if (rightArmAnalyzer != null) { skeletonClient.subscribe(rightArmAnalyzer); } SkeletonUtils.modifyUI( new ThreadStart(() => { try { voiceControl.Fill = new SolidColorBrush(Colors.Cyan); } catch (Exception) { } })); } else { SkeletonUtils.modifyUI( new ThreadStart(() => { try { voiceControl.Fill = new SolidColorBrush(Colors.Orange); } catch (Exception) { } })); } for (int i = 0; i < movements.Length; i++) { if (movements[i] != null) { skeletonClient.subscribe(movements[i]); } } } }
public void setMovementValue(Movement mov, double val) { // Exact movement is 250 // Close movement is 350 if (val > 1000) { val = 1000; } lastMovementValues[(int)mov] = val; double min = val; foreach (Movement pos in Enum.GetValues(typeof(Movement))) { double actual = lastMovementValues[(int)pos]; if (actual < min && actual > 0) { min = actual; } } SkeletonUtils.modifyUI( new ThreadStart(() => { try { MovementDiff.Value = min; } catch (Exception) { } })); if (min < gesturePrecision + progressBarDelta) { SkeletonUtils.modifyUI( new ThreadStart(() => { try { MovementDiffClose.Value = min; } catch (Exception) { } })); } else { SkeletonUtils.modifyUI( new ThreadStart(() => { try { MovementDiffClose.Value = gesturePrecision + progressBarDelta; } catch (Exception) { } })); } if (min < gesturePrecision) { SkeletonUtils.modifyUI( new ThreadStart(() => { try { MovementPrecision.Value = min; } catch (Exception) { } })); } else { SkeletonUtils.modifyUI( new ThreadStart(() => { try { MovementPrecision.Value = gesturePrecision; } catch (Exception) { } })); } }