/// <summary> /// Initialize Kinect. /// </summary> void InitializeKinect() { if (kinectSensor == null) { return; } kinectSensor.ColorStream.Enable(HandInputParams.ColorImageFormat); kinectSensor.DepthStream.Enable(HandInputParams.DepthImageFormat); kinectSensor.SkeletonStream.Enable(new TransformSmoothParameters { Smoothing = 0.5f, Correction = 0.5f, Prediction = 0.5f, JitterRadius = 0.05f, MaxDeviationRadius = 0.04f }); skeletonDisplayManager = new SkeletonDisplayManager(kinectSensor.CoordinateMapper, skeletonCanvas); HandInputParams.ColorFocalLength = kinectSensor.ColorStream.NominalFocalLengthInPixels; HandInputParams.DepthFocalLength = kinectSensor.DepthStream.NominalFocalLengthInPixels; Log.InfoFormat("Color focal length = {0}", HandInputParams.ColorFocalLength); Log.InfoFormat("Depth focal length = {0}", HandInputParams.DepthFocalLength); }
private void Initialize() { if (kinectSensor == null) { return; } audioManager = new AudioStreamManager(kinectSensor.AudioSource); audioBeamAngle.DataContext = audioManager; kinectSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); kinectSensor.ColorFrameReady += kinectRuntime_ColorFrameReady; kinectSensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30); kinectSensor.DepthFrameReady += kinectSensor_DepthFrameReady; kinectSensor.SkeletonStream.Enable(new TransformSmoothParameters { Smoothing = 0.5f, Correction = 0.5f, Prediction = 0.5f, JitterRadius = 0.05f, MaxDeviationRadius = 0.04f }); kinectSensor.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady; swipeGestureRecognizer = new SwipeGestureDetector(); swipeGestureRecognizer.OnGestureDetected += OnGestureDetected; skeletonDisplayManager = new SkeletonDisplayManager(kinectSensor, kinectCanvas); kinectSensor.Start(); LoadCircleGestureDetector(); LoadLetterTPostureDetector(); LoadTriGestureDetector(); //Add Triangle nuiCamera = new BindableNUICamera(kinectSensor); elevationSlider.DataContext = nuiCamera; voiceCommander = new VoiceCommander("record", "stop"); voiceCommander.OrderDetected += voiceCommander_OrderDetected; StartVoiceCommander(); kinectDisplay.DataContext = colorManager; parallelCombinedGestureDetector = new ParallelCombinedGestureDetector(); parallelCombinedGestureDetector.OnGestureDetected += OnGestureDetected; parallelCombinedGestureDetector.Add(swipeGestureRecognizer); parallelCombinedGestureDetector.Add(circleGestureRecognizer); parallelCombinedGestureDetector.Add(triangleGestureRecognizer); //Add Triangle //Media_Loaded(); //btnVideo_Click(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { sensor = KinectSensor.KinectSensors.First(); sensor.Start(); sensor.ColorStream.Enable(); sensor.DepthStream.Enable(); sensor.SkeletonStream.Enable(); Title = sensor.DeviceConnectionId; skeletonDisplayManager = new SkeletonDisplayManager(sensor, imageCanvas); sensor.AllFramesReady += sensor_AllFramesReady; }
private static void AttachKinect() { if (_skeletonDisplayManager != null) { return; } //var kinectSensor = DependencyFactory.Container.Resolve<KinectSensor>(); var testKinect = DependencyFactory.Container.Resolve<TKinect.TKinect>(); var framesCollector = new FramesCollector(testKinect); _skeletonDisplayManager = new SkeletonDisplayManager(_kinectCanvas); framesCollector.FrameReady += (sender, arg) => _skeletonDisplayManager.Draw(arg.Frames.Last().Skeletons, false); }
private static void AttachKinect() { if (_skeletonDisplayManager != null) { return; } //var kinectSensor = DependencyFactory.Container.Resolve<KinectSensor>(); var testKinect = DependencyFactory.Container.Resolve <TKinect.TKinect>(); var framesCollector = new FramesCollector(testKinect); _skeletonDisplayManager = new SkeletonDisplayManager(_kinectCanvas); framesCollector.FrameReady += (sender, arg) => _skeletonDisplayManager.Draw(arg.Frames.Last().Skeletons, false); }
/// <summary> /// Constructor. /// </summary> public MainWindow() { InitializeComponent(); this.MainWindowViewModel = new MainWindowViewModel(); this.Loaded += this.MainWindowViewModel.OnWindowLoaded; this.Closed += this.MainWindowViewModel.OnWindowClosed; this.DataContext = this.MainWindowViewModel; // Skeleton stream. this.SkeletonDisplayManager = new SkeletonDisplayManager(this.MainWindowViewModel.Proxies.KinectSensor, this.ImageCanvas); this.Skeletons = null; this.MainWindowViewModel.Proxies.KinectSensor.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(this.KinectSensorSkeletonFrameReady); }
private void Initialize() { if (sensor == null) { return; } sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); sensor.ColorFrameReady += KinectRuntimeColorFrameReady; sensor.SkeletonStream.Enable(Settings.SmoothingParam); sensor.SkeletonFrameReady += KinectRuntimeSkeletonFrameReady; SkeletonDisplayManager = new SkeletonDisplayManager(sensor, skeleton_canvas); image_stream.DataContext = colorManager; }
private void Initialize() { if (kinectRuntime == null) { return; } kinectRuntime.Initialize(RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor); kinectRuntime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color); kinectRuntime.VideoFrameReady += new EventHandler <ImageFrameReadyEventArgs>(kinectRuntime_VideoFrameReady); kinectRuntime.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(kinectRuntime_SkeletonFrameReady); skeletonDisplayManager = new SkeletonDisplayManager(kinectRuntime.SkeletonEngine, kinectCanvas); gestureRecognizer.TraceTo(gesturesCanvas, System.Windows.Media.Color.FromRgb(255, 0, 0)); gestureRecognizer.OnGestureDetected += new Action <string>(OnGestureDetected); gestureRecognizer.MinimalPeriodBetweenGestures = 2000; }
private void Window_Loaded(object sender, RoutedEventArgs e) { circleKBPath = Path.Combine(Environment.CurrentDirectory, @"data\circleKB.save"); letterT_KBPath = Path.Combine(Environment.CurrentDirectory, @"data\t_KB.save"); try { kinectRuntime = new Runtime(); kinectRuntime.Initialize(RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor); kinectRuntime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color); kinectRuntime.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady; kinectRuntime.VideoFrameReady += kinectRuntime_VideoFrameReady; swipeGestureRecognizer.OnGestureDetected += OnGestureDetected; skeletonDisplayManager = new SkeletonDisplayManager(kinectRuntime.SkeletonEngine, kinectCanvas); kinectRuntime.SkeletonEngine.TransformSmooth = true; var parameters = new TransformSmoothParameters { Smoothing = 1.0f, Correction = 0.1f, Prediction = 0.1f, JitterRadius = 0.05f, MaxDeviationRadius = 0.05f }; kinectRuntime.SkeletonEngine.SmoothParameters = parameters; LoadCircleGestureDetector(); LoadLetterTPostureDetector(); nuiCamera = new BindableNUICamera(kinectRuntime.NuiCamera); elevationSlider.DataContext = nuiCamera; voiceCommander = new VoiceCommander("record", "stop"); voiceCommander.OrderDetected += voiceCommander_OrderDetected; StartVoiceCommander(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/* * Get everything initialized */ public void Initialize() { if (kinectSensor == null) { return; } kinectSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); kinectSensor.ColorFrameReady += kinectRuntime_ColorFrameReady; kinectSensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30); kinectSensor.DepthFrameReady += kinectSensor_DepthFrameReady; kinectSensor.SkeletonStream.Enable(new TransformSmoothParameters { Smoothing = 0.5f, Correction = 0.5f, Prediction = 0.5f, JitterRadius = 0.05f, MaxDeviationRadius = 0.04f }); kinectSensor.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady; skeletonDisplayManager = new SkeletonDisplayManager(kinectSensor, kinectCanvas); //Add keywords that you wan to detect //v_commander = new VoiceCommander("record", "stop", "fly away", "flapping", "start", "finish", "write"); kinectSensor.Start(); //kinectDisplay.DataContext = colorManager; //v_commander.OrderDetected += voiceCommander_OrderDetected; //StartVoiceCommander(); Dictionary <string, GesturePackage> gestureDic = fileManager.loadGesture(); GesturePackage[] values = new GesturePackage[gestureDic.Values.Count]; gestureDic.Values.CopyTo(values, 0); foreach (GesturePackage package in values) { gesture1_left.Add(package.getLeftCoordinates()[0]); gesture1_right.Add(package.getRightCoordinates()[0]); } }
void kinectSensorChooser1_KinectSensorChanged(object sender, DependencyPropertyChangedEventArgs e) { KinectSensor old = (KinectSensor)e.OldValue; StopKinect(old); ksensor = (KinectSensor)e.NewValue; if (ksensor == null) { return; } var parameters = new TransformSmoothParameters { Smoothing = 0.3f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; //sensor.SkeletonStream.Enable(parameters); ksensor.SkeletonStream.Enable(); ksensor.AllFramesReady += new EventHandler <AllFramesReadyEventArgs>(sensor_AllFramesReady); ksensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); ksensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); skeletonDisplayManager = new SkeletonDisplayManager(ksensor, MainCanvas); try { ksensor.Start(); ksensor = ksensor; } catch (System.IO.IOException) { kinectSensorChooser1.AppConflictOccurred(); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { sensor = KinectSensor.KinectSensors.First(); sensor.Start(); sensor.ColorStream.Enable(); sensor.DepthStream.Enable(); sensor.SkeletonStream.Enable(); Title = sensor.DeviceConnectionId; skeletonDisplayManager = new SkeletonDisplayManager(sensor, imageCanvas); gestureDetector = new SwipeGestureDetector(); gestureDetector.DisplayCanvas = imageCanvas; gestureDetector.DisplayColor = Colors.Red; postureDetector = new AlgorithmicPostureDetector(); postureDetector.PostureDetected += postureDetector_PostureDetected; sensor.AllFramesReady += sensor_AllFramesReady; gestureDetector.OnGestureDetected += gestureDetector_OnGestureDetected; }
private void Initialize() { if (kinectRuntime == null) { return; } kinectRuntime.Initialize(RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor); kinectRuntime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color); kinectRuntime.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady; kinectRuntime.VideoFrameReady += kinectRuntime_VideoFrameReady; swipeGestureRecognizer.OnGestureDetected += OnGestureDetected; skeletonDisplayManager = new SkeletonDisplayManager(kinectRuntime.SkeletonEngine, kinectCanvas); kinectRuntime.SkeletonEngine.TransformSmooth = true; var parameters = new TransformSmoothParameters { Smoothing = 1.0f, Correction = 0.1f, Prediction = 0.1f, JitterRadius = 0.05f, MaxDeviationRadius = 0.05f }; kinectRuntime.SkeletonEngine.SmoothParameters = parameters; LoadCircleGestureDetector(); LoadLetterTPostureDetector(); nuiCamera = new BindableNUICamera(kinectRuntime.NuiCamera); elevationSlider.DataContext = nuiCamera; voiceCommander = new VoiceCommander("record", "stop"); voiceCommander.OrderDetected += voiceCommander_OrderDetected; StartVoiceCommander(); }
public void Dispose() { if (skeletonDisplayManager != null) { skeletonDisplayManager = null; } if (colorManager != null) { colorManager = null; } if (depthManager != null) { depthManager = null; } if (speechRecognizer != null) { speechRecognizer.SpeechRecognized -= Speech_Recognized; speechRecognizer.Dispose(); speechRecognizer = null; } if (gestureRecognizer != null) { gestureRecognizer.GestureRecognzied -= Gesture_Recognzied; gestureRecognizer.Dispose(); gestureRecognizer = null; } if (kinectSensor != null) { kinectSensor.ColorFrameReady -= kinectRuntime_ColorFrameReady; kinectSensor.SkeletonFrameReady -= kinectRuntime_SkeletonFrameReady; kinectSensor.ColorFrameReady -= kinectRuntime_ColorFrameReady; kinectSensor.Stop(); kinectSensor = null; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { // Init Kinect try { kinectRuntime = new Runtime(); kinectRuntime.Initialize(RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor); kinectRuntime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color); kinectRuntime.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex); kinectRuntime.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady; kinectRuntime.VideoFrameReady += kinectRuntime_ColorFrameReady; kinectRuntime.SkeletonEngine.TransformSmooth = true; var parameters = new TransformSmoothParameters { Smoothing = 0.7f, Correction = 0.3f, Prediction = 0.4f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; kinectRuntime.SkeletonEngine.SmoothParameters = parameters; skeletonDisplayManager = new SkeletonDisplayManager(kinectRuntime.SkeletonEngine, skeletonCanvas); // Events rightHandGestureRecognizer.OnGestureDetected += rightHandGestureRecognizer_OnGestureDetected; } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); kinectRuntime = null; } }
public void LoadSkeletonDisplayManager(Canvas skeletonCanvas) { skeletonDisplayManager = new SkeletonDisplayManager(kinectSensor, skeletonCanvas); }
private void Window_Loaded(object sender, RoutedEventArgs e) { // Init Kinect try { kinectRuntime = new Runtime(); kinectRuntime.Initialize(RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor); kinectRuntime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color); kinectRuntime.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex); kinectRuntime.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady; kinectRuntime.VideoFrameReady += kinectRuntime_ColorFrameReady; kinectRuntime.SkeletonEngine.TransformSmooth = true; var parameters = new TransformSmoothParameters { Smoothing = 0.7f, Correction = 0.3f, Prediction = 0.4f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; kinectRuntime.SkeletonEngine.SmoothParameters = parameters; skeletonDisplayManager = new SkeletonDisplayManager(kinectRuntime.SkeletonEngine, skeletonCanvas); // Events rightHandGestureRecognizer.OnGestureDetected += rightHandGestureRecognizer_OnGestureDetected; } catch(Exception ex ) { MessageBox.Show(ex.Message); Close(); kinectRuntime = null; } }