public KinectNuiService() { if (KinectSensor.KinectSensors.Count == 0) { return; } this.handsRaisingStart = new Dictionary <JointType, DateTime>(); this.handsRaising = new Dictionary <JointType, bool>(); this.handsWaitingToLower = new Dictionary <JointType, bool>(); this.BoundsWidth = .5d; this.BoundsDepth = .5d; this.MinDistanceFromCamera = 1.0d; this.sensor = KinectSensor.KinectSensors[0]; this.sensor.AllFramesReady += new EventHandler <AllFramesReadyEventArgs>(sensor_AllFramesReady); this.initialized = true; var parameters = new TransformSmoothParameters(); parameters.Smoothing = 0.7f; parameters.Correction = 0.9f; parameters.Prediction = 0.5f; parameters.JitterRadius = 0.5f; parameters.MaxDeviationRadius = 0.5f; this.sensor.SkeletonStream.Enable(parameters); this.sensor.SkeletonStream.Enable(); this.sensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30); this.sensor.Start(); DebugLogWriter.WriteMessage("Kinect initialized."); }
public void EnableSkeleton(bool enable, bool smooth, TransformSmoothParameters sp) { if (enable) { //Need to disable if (this.Runtime.SkeletonStream.IsEnabled) { this.Runtime.SkeletonStream.Disable(); } if (smooth) { this.Runtime.SkeletonStream.Enable(sp); } else { this.Runtime.SkeletonStream.Enable(); } this.Runtime.SkeletonFrameReady += this.Runtime_SkeletonFrameReady; } else { this.Runtime.SkeletonStream.Disable(); this.Runtime.SkeletonFrameReady -= this.Runtime_SkeletonFrameReady; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (wlacz_kinect) { foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { this.kinectSensor = potentialSensor; break; } } //Dodatkowe parametry pozwalajace na usuniecie drgan var parameters = new TransformSmoothParameters { Smoothing = 0.75f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 0.05f, MaxDeviationRadius = 0.04f }; //Inicjalizacja trybu Skeletal tracking kinectSensor.SkeletonStream.Enable(parameters); //Dodanie zdarzenia, przechwytujacego dane this.kinectSensor.SkeletonFrameReady += this.nui_SkeletonFrameReady; kinectSensor.Start(); } }
private void startKinect() { if (KinectSensor.KinectSensors.Count > 0) { kinect = KinectSensor.KinectSensors[0]; if (kinect == null) { return; } //Get Depth Stream, Color Stream kinect.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); kinect.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); var parameters = new TransformSmoothParameters { Smoothing = 0.5f, Correction = 0.5f, Prediction = 0.5f, JitterRadius = 0.05f, MaxDeviationRadius = 0.04f }; kinect.SkeletonStream.Enable(parameters); kinect.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(kinect_SkeletonFrameReady); kinectColorViewer1.Kinect = kinect; //kinectSkeletonViewer1.Kinect = kinect; kinect.Start(); //OperationRecognizer(); } else { MessageBox.Show("No kinect device found"); } }
/// <summary> /// Starts up Kinect /// </summary> void StartKinect() { try { kinect = KinectSensor.KinectSensors.FirstOrDefault(); kinect.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(runtime_SkeletonFrameReady); TransformSmoothParameters parameters = new TransformSmoothParameters() { Smoothing = 0.75f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 0.05f, MaxDeviationRadius = 0.4f }; kinect.SkeletonStream.Enable(parameters); this.skeletonData = new Skeleton[kinect.SkeletonStream.FrameSkeletonArrayLength]; kinect.Start(); Trace.WriteLine("Kinect initialized"); } catch (Exception) { Trace.WriteLine("Error while initializing Kinect. Trying again in 5 seconds..."); kinectRetryTimer.Start(); } }
private void WindowLoaded(object sender, RoutedEventArgs e) { this.sensor = KinectSensor.KinectSensors[0]; this.sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Default; /* SkeletonFrameReady is an event * public event EventHandler<SkeletonFrameReadyEventArgs> SkeletonFrameReady * SkeletonFrameReadyEventArgs holds data about SkeletonFrameReady event * It is inherited from EventArgs empty class * It returns skeleton image data upon success or null upon failure * The following statement suggests that skeletonFrameReady eventhandler method to register with * SkeletonFrameReady event */ this.sensor.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(skeletonFrameReady); var smoothParameters = new TransformSmoothParameters { Correction = 0.05f, JitterRadius = 0.5f, MaxDeviationRadius = 0.1f, Prediction = 0.1f, Smoothing = 0.8f }; this.sensor.SkeletonStream.Enable(smoothParameters); this.sensor.Start(); }
/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> public override void Initialize() { // TODO: Add your initialization code here //initialize Kinect SDK LoadGameComponents(); kinectSensor = (from sensorToCheck in KinectSensor.KinectSensors where sensorToCheck.Status == KinectStatus.Connected select sensorToCheck).FirstOrDefault(); kinectSensor.DepthStream.Enable(); TransformSmoothParameters param = new TransformSmoothParameters(); param.Smoothing = 0.2f; param.Correction = 0.0f; param.Prediction = 0.0f; param.JitterRadius = 0.2f; param.MaxDeviationRadius = 0.3f; kinectSensor.SkeletonStream.Enable(param); kinectSensor.Start(); kinectSensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(kinectSensor_AllFrameReady); //setup speech recognition // SetupSpeech(); base.Initialize(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { //Initialize to do skeletal tracking nui.Initialize(RuntimeOptions.UseSkeletalTracking); #region TransformSmooth //Must set to true and set after call to Initialize nui.SkeletonEngine.TransformSmooth = true; //Use to transform and reduce jitter var parameters = new TransformSmoothParameters { Smoothing = .1f, // default .5f Correction = 0.1f, Prediction = 0.0f, JitterRadius = 0.2f, // default .005f MaxDeviationRadius = 0.8f }; nui.SkeletonEngine.SmoothParameters = parameters; #endregion //add event to receive skeleton data nui.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(nui_SkeletonFrameReady); }
/// <summary> /// Starts up the SkeletonSlam class. /// </summary> public VoiceControl() { kinectSensor = KinectSensor.KinectSensors[0]; TransformSmoothParameters smoothingParam = new TransformSmoothParameters(); { smoothingParam.Smoothing = 0.5f; smoothingParam.Correction = 0.5f; smoothingParam.Prediction = 0.5f; smoothingParam.JitterRadius = 0.05f; smoothingParam.MaxDeviationRadius = 0.04f; }; kinectSensor.SkeletonStream.Enable(smoothingParam); kinectSensor.SkeletonFrameReady += getSkeleton; sre = CreateSpeechRecognizer(); kinectSensor.Start(); sre.SetInputToAudioStream(kinectSensor.AudioSource.Start(), new SpeechAudioFormatInfo( EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null)); sre.RecognizeAsync(RecognizeMode.Multiple); reset(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { img2.Margin = img.Margin; img2.Width = img.Width; img2.Height = img.Height; drawingGroup = new DrawingGroup(); connectKinect(); if (sensor != null) { sensor.Start(); } else { return; } sensor.SkeletonFrameReady += sensor_SkeletonFrameReady; sensor.ColorFrameReady += sensor_ColorFrameReady; sensor.DepthFrameReady += sensor_DepthFrameReady; TransformSmoothParameters trans = new TransformSmoothParameters(); //Minimum /*trans.Smoothing = 0.5f; * trans.Correction = 0.5f; * trans.Prediction = 0.5f; * trans.JitterRadius = 0.05f; * trans.MaxDeviationRadius = 0.04f; * * //Medium * trans.Smoothing = 0.5f; * trans.Correction = 0.1f; * trans.Prediction = 0.5f; * trans.JitterRadius = 0.1f; * trans.MaxDeviationRadius = 0.1f; */ //Maximum trans.Smoothing = 0.7f; trans.Correction = 0.3f; trans.Prediction = 1.0f; trans.JitterRadius = 1.0f; trans.MaxDeviationRadius = 1.0f; //sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated; //sensor.DepthStream.Range = DepthRange.Near; sensor.ElevationAngle = 0; sensor.SkeletonStream.Enable(trans); sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); sensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); colorPixels = new byte[sensor.ColorStream.FramePixelDataLength]; dI = new DrawingImage(this.drawingGroup); imgSource = new WriteableBitmap(this.sensor.ColorStream.FrameWidth, this.sensor.ColorStream.FrameHeight, 96.0, 96.0, PixelFormats.Bgr32, null); img.Source = imgSource; img2.Source = dI; }
private void WindowLoaded(object sender, RoutedEventArgs e) { this.sensor = KinectSensor.KinectSensors[0]; this.sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Default; var smoothParameters = new TransformSmoothParameters { Correction = 0.1f, JitterRadius = 0.05f, MaxDeviationRadius = 0.05f, Prediction = 0.1f, Smoothing = 0.5f }; this.sensor.SkeletonStream.Enable(smoothParameters); this.sensor.SkeletonFrameReady += this.skeletonFrameReady; this.sensor.ColorStream.Enable(); this.colorPixels = new byte[this.sensor.ColorStream.FramePixelDataLength]; this.colorBitmap = new WriteableBitmap(this.sensor.ColorStream.FrameWidth, this.sensor.ColorStream.FrameHeight, 96.0, 96.0, PixelFormats.Bgr32, null); this.image.Source = this.colorBitmap; this.sensor.ColorFrameReady += this.colorFrameReady; this.sensor.Start(); thing.Shape = new Ellipse(); thing.Shape.Width = 30; thing.Shape.Height = 30; thing.Shape.Fill = new SolidColorBrush(Color.FromRgb(0, 255, 255)); thing.Center.X = 300; thing.Center.Y = 0; thing.Shape.SetValue(Canvas.LeftProperty, (thing.Center.X - thing.Shape.Width)); thing.Shape.SetValue(Canvas.TopProperty, (thing.Center.Y - thing.Shape.Width)); canvas1.Children.Add(thing.Shape); }
private static TransformSmoothParameters SmoothingParams() { TransformSmoothParameters verySmoothParam = new TransformSmoothParameters(); { verySmoothParam.Smoothing = 0.7f; verySmoothParam.Correction = 0.3f; verySmoothParam.Prediction = 1.0f; verySmoothParam.JitterRadius = 1.0f; verySmoothParam.MaxDeviationRadius = 1.0f; }; TransformSmoothParameters smoothParam = new TransformSmoothParameters(); { smoothParam.Smoothing = 0.5f; smoothParam.Correction = 0.1f; smoothParam.Prediction = 0.5f; smoothParam.JitterRadius = 0.1f; smoothParam.MaxDeviationRadius = 0.1f; }; TransformSmoothParameters fastSmoothingParam = new TransformSmoothParameters(); { fastSmoothingParam.Smoothing = 0.5f; fastSmoothingParam.Correction = 0.5f; fastSmoothingParam.Prediction = 0.5f; fastSmoothingParam.JitterRadius = 0.05f; fastSmoothingParam.MaxDeviationRadius = 0.04f; }; return verySmoothParam; }
//Méthode d'initialisation de la Kinect public void StartKinectST() { //Instancitation d'un objet kinectSensor kinectSensor = KinectSensor.KinectSensors[0]; kinectSensor.Start(); // SmoothParamater pour éliminer le bruit TransformSmoothParameters parameters = new TransformSmoothParameters { Smoothing = 0.3f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; // Ouverture des flux kinectSensor.ColorStream.Enable(); kinectSensor.DepthStream.Enable(); kinectSensor.SkeletonStream.Enable(parameters); kinectSensor.SkeletonStream.OpenNextFrame(33); kinectSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Default; kinectSensor.SkeletonFrameReady += kinect_SkeletonFrameReady; while (true) { } }
private void SetupKinect() { if (Runtime.Kinects.Count == 0) { this.Title = "No Kinect connected"; } else { //use first Kinect nui = Runtime.Kinects[0]; //Initialize to do skeletal tracking nui.Initialize(RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor | RuntimeOptions.UseDepthAndPlayerIndex); //add event to receive skeleton data nui.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(nui_SkeletonFrameReady); //to experiment, toggle TransformSmooth between true & false and play with parameters nui.SkeletonEngine.TransformSmooth = true; TransformSmoothParameters parameters = new TransformSmoothParameters(); // parameters used to smooth the skeleton data parameters.Smoothing = 0.3f; parameters.Correction = 0.3f; parameters.Prediction = 0.4f; parameters.JitterRadius = 0.7f; parameters.MaxDeviationRadius = 0.2f; nui.SkeletonEngine.SmoothParameters = parameters; } }
public void ActivateSkeletFlow(SkeletonFlowHandler skeletonFlowHandler, TransformSmoothParameters? smoothingParam = null) { if(_kinect == null) throw new Exception("Нет инициализированных устройств"); _skeletonFlowHandler = skeletonFlowHandler; //var smoothingParam = new TransformSmoothParameters(); //{ // smoothingParam.Smoothing = 0.7f; // smoothingParam.Correction = 0.3f; // smoothingParam.Prediction = 1.0f; // smoothingParam.JitterRadius = 1.0f; // smoothingParam.MaxDeviationRadius = 1.0f; //}; if (smoothingParam.HasValue) _kinect.SkeletonStream.Enable((TransformSmoothParameters)smoothingParam); else _kinect.SkeletonStream.Enable(); //Сидячий режим //_kinect.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated; _kinect.SkeletonFrameReady += this.SensorSkeletonFrameReady; }
/// <summary> /// Starts up the SkeletonSlam class. /// </summary> public SkeletonSlam() { halfSpinFlag = false; fullSpinFlag = false; fullRightFlag = false; fullLeftFlag = false; halfSpinRightFlag = false; halfSpinLeftFlag = false; quarterRightFlag = false; quarterLeftFlag = false; //kinectSensor = KinectSensor.KinectSensors[0]; TransformSmoothParameters smoothingParam = new TransformSmoothParameters(); { smoothingParam.Smoothing = 0.5f; smoothingParam.Correction = 0.5f; smoothingParam.Prediction = 0.5f; smoothingParam.JitterRadius = 0.05f; smoothingParam.MaxDeviationRadius = 0.04f; }; //kinectSensor.SkeletonStream.Enable(smoothingParam); //kinectSensor.Start(); reset(); //kinectSensor.SkeletonFrameReady += getSkeleton; //processHandMove = new Thread(ProcessHandMove); //processHandMove.Start(); }
public KinectNuiService() { if (KinectSensor.KinectSensors.Count == 0) { return; } this.handsRaisingStart = new Dictionary<JointType, DateTime>(); this.handsRaising = new Dictionary<JointType, bool>(); this.handsWaitingToLower = new Dictionary<JointType, bool>(); this.BoundsWidth = .5d; this.BoundsDepth = .5d; this.MinDistanceFromCamera = 1.0d; this.sensor = KinectSensor.KinectSensors[0]; this.sensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(sensor_AllFramesReady); this.initialized = true; var parameters = new TransformSmoothParameters(); parameters.Smoothing = 0.7f; parameters.Correction = 0.9f; parameters.Prediction = 0.5f; parameters.JitterRadius = 0.5f; parameters.MaxDeviationRadius = 0.5f; this.sensor.SkeletonStream.Enable(parameters); this.sensor.SkeletonStream.Enable(); this.sensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30); this.sensor.Start(); DebugLogWriter.WriteMessage("Kinect initialized."); }
/// <summary> /// Handle insertion of Kinect sensor. /// </summary> /// AUTHOR: TAMER & KHALED private void InitializeNui() { var index = 0; while (this.nui == null && index < KinectSensor.KinectSensors.Count) { this.nui = KinectSensor.KinectSensors[index]; this.nui.Start(); } try { this.skeletons = new Skeleton[this.nui.SkeletonStream.FrameSkeletonArrayLength]; var parameters = new TransformSmoothParameters { Smoothing = 0.75f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 0.05f, MaxDeviationRadius = 0.04f }; this.nui.SkeletonStream.Enable(parameters); this.nui.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); } catch (Exception) { return; } this.nui.SkeletonFrameReady += this.OnSkeletonFrameReady; gestureController = new GestureController(); gestureController.GestureRecognized += OnGestureRecognized; InitializeGestures(); }
void kinectSensorChooser1_KinectSensorChanged(object sender, DependencyPropertyChangedEventArgs e) { KinectSensor oldSensor = (KinectSensor)e.OldValue; stopKinect(oldSensor); KinectSensor newSensor = (KinectSensor)e.NewValue; newSensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); newSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); var parameters = new TransformSmoothParameters { Smoothing = 0.3f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; //newSensor.SkeletonStream.Enable(parameters); newSensor.SkeletonStream.Enable(); newSensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(newSensor_AllFramesReady); try { newSensor.Start(); } catch (System.IO.IOException) { kinectSensorChooser1.AppConflictOccurred(); } }
public void StartKinect() { // Checks to see how many Kinects are connected to the system. If None then exit. if (KinectSensor.KinectSensors.Count == 0) { Console.Out.WriteLine("There are no Kinects Connected"); return; } // If there is a Kinect connected, get the Kinect ks = KinectSensor.KinectSensors[0]; ks.Start(); //Sets the initial elevation angle of the connect to 0 degrees ks.ElevationAngle = 0; // Set smoothing parameters for when Kinect is tracking a skeleton TransformSmoothParameters parameters = new TransformSmoothParameters() { Smoothing = 0.7f, Correction = 0.3f, Prediction = 0.4f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f, }; ks.SkeletonStream.Enable(parameters); ks.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(ks_SkeletonFrameReady); }
/// <summary> /// Initializes the Kinect sensor. /// </summary> /// <returns>bool value true if the sensor initialised correctly</returns> private bool InitializeNui() { if (this.kinectRunTime == null) { return(false); } try { this.kinectRunTime.Initialize(RuntimeOptions.UseDepth | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor); } catch (Exception exception) { Console.WriteLine(exception.ToString()); return(false); } this.kinectRunTime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color); this.kinectRunTime.SkeletonEngine.TransformSmooth = true; var parameters = new TransformSmoothParameters { Smoothing = 0.75f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 0.05f, MaxDeviationRadius = 0.04f }; this.kinectRunTime.SkeletonEngine.SmoothParameters = parameters; return(true); }
private void SetupKinect() { // Check to see if there are any Kinect devices connected. if (Runtime.Kinects.Count == 0) { MessageBox.Show("No Kinect connected"); } else { // Use first Kinect. kinectRuntime = Runtime.Kinects[0]; // Initialize to return skeletal data. kinectRuntime.Initialize(RuntimeOptions.UseSkeletalTracking); // Attach to the event to receive skeleton frame data. kinectRuntime.SkeletonFrameReady += KinectRuntime_SkeletonFrameReady; kinectRuntime.SkeletonEngine.TransformSmooth = true; TransformSmoothParameters parameters = new TransformSmoothParameters(); parameters.Smoothing = 0.5f; parameters.Correction = 0.3f; parameters.Prediction = 0.2f; parameters.JitterRadius = .2f; parameters.MaxDeviationRadius = 0.5f; kinectRuntime.SkeletonEngine.SmoothParameters = parameters; kinectRuntime.NuiCamera.ElevationAngle = 0; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (KinectSensor.KinectSensors.Count > 0) { _sensor = KinectSensor.KinectSensors[0]; if (_sensor.Status == KinectStatus.Connected) { _sensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); _sensor.AllFramesReady += new EventHandler <AllFramesReadyEventArgs>(_sensor_AllFramesReady); var parameters = new TransformSmoothParameters { Smoothing = 0.3f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; _sensor.SkeletonStream.Enable(parameters); _sensor.Start(); } } }
public void StartKinect() { // Checks to see how many Kinects are connected to the system. If None then exit. if (KinectSensor.KinectSensors.Count == 0) { Console.Out.WriteLine("There are no Kinects Connected"); return; } // If there is a Kinect connected, get the Kinect ks = KinectSensor.KinectSensors[0]; ks.Start(); //Sets the initial elevation angle of the connect to 0 degrees ks.ElevationAngle = 0; // Set smoothing parameters for when Kinect is tracking a skeleton TransformSmoothParameters parameters = new TransformSmoothParameters() { Smoothing = 0.7f, Correction = 0.3f, Prediction = 0.4f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f, }; ks.SkeletonStream.Enable(parameters); ks.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(ks_SkeletonFrameReady); }
public override void Load() { try { IsEnabled = true; _kinect = KinectSensor.KinectSensors[0]; var parameters = new TransformSmoothParameters { Smoothing = 0.3f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; _kinect.SkeletonStream.Enable(parameters); _kinect.AllFramesReady += _kinect_AllFramesReady; _kinect.Start(); RawRotation = Quaternion.Identity; } catch (Exception exc) { Logger.Instance.Error(exc.Message, exc); IsEnabled = false; } }
public MainWindow() { InitializeComponent(); this.Loaded += new RoutedEventHandler(MainWindow_Loaded); this.Unloaded += new RoutedEventHandler(MainWindow_Unloaded); //平滑处理 TransformSmoothParameters parameters = new TransformSmoothParameters(); parameters.Smoothing = 0.7f; parameters.Correction = 0.3f; parameters.Prediction = 0.4f; parameters.JitterRadius = 1.0f; parameters.MaxDeviationRadius = 0.5f; sensor.SkeletonStream.Enable(parameters); //开启骨架功能 sensor.SkeletonStream.Enable(); //开启颜色功能 sensor.ColorStream.Enable(); skeletonBrushes = new Brush[] { Brushes.Black, Brushes.Crimson, Brushes.Indigo, Brushes.DodgerBlue, Brushes.Purple, Brushes.Pink }; KinectSensor.KinectSensors.StatusChanged += KinectSensors_StatusChanged; this.sensor = KinectSensor.KinectSensors.FirstOrDefault(x => x.Status == KinectStatus.Connected); }
void StartKinectSt() { // Get first Kinect Sensor _kinect = KinectSensor.KinectSensors.FirstOrDefault(s => s.Status == KinectStatus.Connected); // Enable skeletal tracking, default = standing _kinect.SkeletonStream.TrackingMode = SkeletonTrackingMode.Default; // Define smoothing parameters TransformSmoothParameters smoothingParam = new TransformSmoothParameters(); { smoothingParam.Smoothing = 0.5f; smoothingParam.Correction = 0.5f; smoothingParam.Prediction = 0.5f; smoothingParam.JitterRadius = 0.05f; smoothingParam.MaxDeviationRadius = 0.04f; } // Smooth the position data _kinect.SkeletonStream.Enable(smoothingParam); // Allocate ST data _skeletonData = new Skeleton[_kinect.SkeletonStream.FrameSkeletonArrayLength]; // Get Ready for Skeleton Ready Events _kinect.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(kinect_SkeletonFrameReady); // Start Kinect sensor _kinect.Start(); }
private KinectHelper(TransformSmoothParameters tsp, bool near = false, ColorImageFormat colorFormat = ColorImageFormat.RgbResolution1280x960Fps12, DepthImageFormat depthFormat = DepthImageFormat.Resolution640x480Fps30) { _kinectSensor = KinectSensor.KinectSensors.FirstOrDefault(s => s.Status == KinectStatus.Connected); if (_kinectSensor == null) { throw new Exception("No Kinect-Sensor found."); } if (near) { _kinectSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated; _kinectSensor.DepthStream.Range = DepthRange.Near; _kinectSensor.SkeletonStream.EnableTrackingInNearRange = true; } DepthImageFormat = depthFormat; ColorImageFormat = colorFormat; _kinectSensor.SkeletonStream.Enable(tsp); _kinectSensor.ColorStream.Enable(colorFormat); _kinectSensor.DepthStream.Enable(depthFormat); _kinectSensor.AllFramesReady += AllFramesReady; _kinectSensor.Start(); _faceTracker = new FaceTracker(_kinectSensor); }
private void Window_Loaded(object sender, RoutedEventArgs e) { sensor = KinectSensor.KinectSensors.FirstOrDefault(s => s.Status == KinectStatus.Connected); // Get first Kinect Sensor depthFormat = sensor.DepthStream.Format; sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); colorPixels = new byte[this.sensor.ColorStream.FramePixelDataLength]; colorBitmap = new WriteableBitmap(this.sensor.ColorStream.FrameWidth, this.sensor.ColorStream.FrameHeight, 96.0, 96.0, PixelFormats.Bgr32, null); this.Image.Source = this.colorBitmap; sensor.ColorFrameReady += this.SensorColorFrameReady; var parameters = new TransformSmoothParameters { Smoothing = 0.3f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; sensor.SkeletonStream.Enable(parameters); sensor.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(nui_SkeletonFrameReady); try { sensor.Start(); sensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30); depthFrame = sensor.DepthStream.OpenNextFrame(0); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } }
public Mover(GameStateManagementGame myGame) { thisGameIsAwesome = myGame; kinectSensor = new Runtime(); try { kinectSensor.Initialize(RuntimeOptions.UseSkeletalTracking); kinectSensor.SkeletonEngine.TransformSmooth = true; TransformSmoothParameters p = new TransformSmoothParameters { Smoothing = 0.75f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 0.05f, MaxDeviationRadius = 0.04f }; kinectSensor.SkeletonEngine.SmoothParameters = p; } catch (Exception ex) { } }
private void startKinect() { if (KinectSensor.KinectSensors.Count > 0) { //选择第一个Kinect设备 _kinect = KinectSensor.KinectSensors[0]; //启用彩色摄像头,红外线和骨骼跟踪 _kinect.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); _kinect.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); var parameters = new TransformSmoothParameters { Smoothing = 0.5f, Correction = 0.5f, Prediction = 0.5f, JitterRadius = 0.05f, MaxDeviationRadius = 0.04f }; _kinect.SkeletonStream.Enable(parameters); _kinect.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(Kinect_SkeletonFrameReady); labelTracked.Visibility = System.Windows.Visibility.Visible; //注册彩色和深度模型 _kinect.ColorFrameReady += new EventHandler <ColorImageFrameReadyEventArgs>(_kinect_ColorFrameReady); _kinect.DepthFrameReady += new EventHandler <DepthImageFrameReadyEventArgs>(_kinect_DepthFrameReady); _kinect.Start(); } else { MessageBox.Show("没有发现设备"); } }
/// <summary> /// Starts up Kinect /// </summary> void StartKinect() { try { kinect = KinectSensor.KinectSensors.FirstOrDefault(); kinect.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(runtime_SkeletonFrameReady); TransformSmoothParameters parameters = new TransformSmoothParameters() { Smoothing = 0.75f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 0.05f, MaxDeviationRadius = 0.4f }; kinect.SkeletonStream.Enable(parameters); this.skeletonData = new Skeleton[kinect.SkeletonStream.FrameSkeletonArrayLength]; kinect.Start(); Trace.WriteLine("Kinect initialized"); } catch (Exception) { Trace.WriteLine("Error while initializing Kinect. Trying again in 5 seconds..."); kinectRetryTimer.Start(); } }
public KinectGrabWheelController(WheelDelegate wheelDelegate, ScreenManager screenManager, KinectSensor kinect) { this.device = screenManager.GraphicsDevice; this.wheelDelegate = wheelDelegate; position = new Vector2(); positionScreen = new Vector2(); this.kinectSensor = kinect; //if (!kinect.IsRunning) //{ var parameters = new TransformSmoothParameters { Smoothing = 0.1f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; kinect.SkeletonStream.Enable(parameters); kinect.DepthStream.Enable(); kinect.ColorStream.Enable(); kinect.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(ks_AllFramesReady); interactionStream = new Microsoft.Kinect.Toolkit.Interaction.InteractionStream(kinect, new myIntClient()); interactionStream.InteractionFrameReady += new EventHandler<InteractionFrameReadyEventArgs>(intStream_InteractionFrameReady); kinect.Start(); //} }
//Point x; private void WindowLoaded(object sender, RoutedEventArgs e) { this.sensor = KinectSensor.KinectSensors[0]; this.sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated; this.sensor.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(skeletonFrameReady); var smoothParameters = new TransformSmoothParameters { Correction = 0.05f, JitterRadius = 0.5f, MaxDeviationRadius = 0.1f, Prediction = 0.1f, Smoothing = 0.8f }; this.sensor.SkeletonStream.Enable(smoothParameters); this.sensor.Start(); //thing.ellipse = new Ellipse(); //thing.ellipse.Width = 5; //thing.ellipse.Height = 5; //thing.ellipse.Fill = new SolidColorBrush(Colors.Black); //skeletonCanvas.Children.Add(thing.ellipse); }
private void SetupKinect() { if (Runtime.Kinects.Count == 0) { this.Title = "No Kinect connected"; } else { //use first Kinect nui = Runtime.Kinects[0]; //Initialize to do skeletal tracking nui.Initialize(RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor | RuntimeOptions.UseDepthAndPlayerIndex); //add event to receive skeleton data nui.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(nui_SkeletonFrameReady); //to experiment, toggle TransformSmooth between true & false and play with parameters nui.SkeletonEngine.TransformSmooth = true; TransformSmoothParameters parameters = new TransformSmoothParameters(); // parameters used to smooth the skeleton data parameters.Smoothing = 0.3f; parameters.Correction = 0.3f; parameters.Prediction = 0.4f; parameters.JitterRadius = 0.7f; parameters.MaxDeviationRadius = 0.2f; nui.SkeletonEngine.SmoothParameters = parameters; } }
public void Initialize(GraphicsDeviceManager graphics) { try { kinect = KinectSensor.KinectSensors[0]; //kinect.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); //kinect.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30); TransformSmoothParameters smoothingParam = new TransformSmoothParameters(); smoothingParam.Smoothing = 0.5f; smoothingParam.Correction = 0.5f; smoothingParam.Prediction = 0.5f; smoothingParam.JitterRadius = 0.05f; smoothingParam.MaxDeviationRadius = 0.04f; kinect.SkeletonStream.Enable(smoothingParam); kinect.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(kinect_AllFramesReady); ready = true; kinect.Start(); colorVideo = new Texture2D(graphics.GraphicsDevice, kinect.ColorStream.FrameWidth, kinect.ColorStream.FrameHeight); depthVideo = new Texture2D(graphics.GraphicsDevice, kinect.DepthStream.FrameWidth, kinect.DepthStream.FrameHeight); Debug.WriteLineIf(debugging, kinect.Status); status = "ok"; } catch (Exception e) { Debug.WriteLine(e.ToString()); status = "error"; } }
private KinectHelper(TransformSmoothParameters tsp, bool near = false, ColorImageFormat colorFormat = ColorImageFormat.RgbResolution1280x960Fps12, DepthImageFormat depthFormat = DepthImageFormat.Resolution640x480Fps30) { _kinectSensor = KinectSensor.KinectSensors.FirstOrDefault(s => s.Status == KinectStatus.Connected); if (_kinectSensor == null) { throw new Exception("No Kinect-Sensor found."); } if (near) { _kinectSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated; _kinectSensor.DepthStream.Range = DepthRange.Near; _kinectSensor.SkeletonStream.EnableTrackingInNearRange = true; } DepthImageFormat = depthFormat; ColorImageFormat = colorFormat; _kinectSensor.SkeletonStream.Enable(tsp); _kinectSensor.ColorStream.Enable(colorFormat); _kinectSensor.DepthStream.Enable(depthFormat); _kinectSensor.AllFramesReady += AllFramesReady; _kinectSensor.Start(); _faceTracker = new FaceTracker(_kinectSensor); }
public override void Load() { try { IsEnabled = true; _kinect = KinectSensor.KinectSensors[0]; var parameters = new TransformSmoothParameters { Smoothing = 0.3f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; _kinect.SkeletonStream.Enable(parameters); _kinect.AllFramesReady += _kinect_AllFramesReady; _kinect.Start(); RawRotation = Quaternion.Identity; } catch (Exception exc) { Logger.Instance.Error(exc.Message, exc); IsEnabled = false; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { Runtime kinectRuntime = new Runtime(); kinectRuntime.Initialize(RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking); kinectRuntime.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex); kinectRuntime.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady; kinectRuntime.DepthFrameReady += kinectRuntime_DepthFrameReady; kinectRuntime.SkeletonEngine.TransformSmooth = true; var parameters = new TransformSmoothParameters { Smoothing = 0.75f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 0.05f, MaxDeviationRadius = 0.04f }; kinectRuntime.SkeletonEngine.SmoothParameters = parameters; using (game = new Game1()) { game.Exiting += game_Exiting; game.Run(); } kinectRuntime.Uninitialize(); }
// Initialize kinect public bool Init( ) { this.kinectSensor = KinectSensor.KinectSensors.Where(s => s.Status == KinectStatus.Connected).FirstOrDefault( ); if (this.kinectSensor == null) { return(false); } // some parameters to make smooth skeleton recognition. native method of kinect TransformSmoothParameters smoothingParam = new TransformSmoothParameters( ); { smoothingParam.Smoothing = 0.7f; smoothingParam.Correction = 0.3f; smoothingParam.Prediction = 1.0f; smoothingParam.JitterRadius = 1.0f; smoothingParam.MaxDeviationRadius = 1.0f; }; //this.kinectSensor.ColorStream.Enable ( ColorImageFormat.RgbResolution640x480Fps30 ); this.kinectSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated; this.kinectSensor.SkeletonStream.Enable(smoothingParam); this.kinectSensor.Start( ); this.kinectSensor.SkeletonFrameReady += this.SkeletonFrameReady; return(true); }
private void SetupKinect() { if (Runtime.Kinects.Count == 0) { this.Title = "No Kinect connected"; } else { //use first Kinect nui = Runtime.Kinects[0]; //Initialize to do skeletal tracking nui.Initialize(RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor); //add event to receive skeleton data nui.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(nui_SkeletonFrameReady); nui.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color); nui.SkeletonEngine.TransformSmooth = true; TransformSmoothParameters parameters = new TransformSmoothParameters(); parameters.Smoothing = 0.3f; parameters.Correction = 0.9f; parameters.Prediction = 0.9f; parameters.JitterRadius = 1.0f; parameters.MaxDeviationRadius = 0.5f; nui.SkeletonEngine.SmoothParameters = parameters; } }
public void Initialize(KinectSensor sensor) { this.sensor = sensor; coordinateMapper = new CoordinateMapper(sensor); //Prepare for RGB image information receive sensor.ColorStream.Enable(ColorImageFormat.RgbResolution1280x960Fps12); imageSize = new Int32Rect(0, 0, sensor.ColorStream.FrameWidth, sensor.ColorStream.FrameHeight); stride = imageSize.Width * 4; // blue, green, red, empty colorData = new byte[sensor.ColorStream.FramePixelDataLength]; ColorBitmap = new WriteableBitmap(imageSize.Width, imageSize.Height, 96, 96, PixelFormats.Bgr32, null); TransformSmoothParameters smooth = new TransformSmoothParameters() { Smoothing = Parameters.Kinect.Smoothing, Correction = Parameters.Kinect.Correction, Prediction = Parameters.Kinect.Prediction, JitterRadius = Parameters.Kinect.JitterRadius, MaxDeviationRadius = Parameters.Kinect.MaxDeviationRadius }; sensor.SkeletonStream.TrackingMode = Parameters.Kinect.TrackingMode; sensor.SkeletonStream.Enable(smooth); sensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(sensor_SkeletonFrameReady); sensor.ColorFrameReady += new EventHandler<ColorImageFrameReadyEventArgs>(sensor_ColorFrameReady); sensor.Start(); Initialized = true; }
private void Window_Loaded(object sender, RoutedEventArgs e) { _runtime.SkeletonFrameReady += _runtime_SkeletonFrameReady; try { _runtime.Initialize(RuntimeOptions.UseDepth | RuntimeOptions.UseSkeletalTracking); } catch(Exception ex) { MessageBox.Show("Could not initialize Kinect device: " + ex.Message); } _runtime.SkeletonEngine.TransformSmooth = true; TransformSmoothParameters parameters = new TransformSmoothParameters(); parameters.Smoothing = 0.7f; parameters.Correction = 0.3f; parameters.Prediction = 0.4f; parameters.JitterRadius = 1.0f; parameters.MaxDeviationRadius = 0.5f; _runtime.SkeletonEngine.SmoothParameters = parameters; try { _runtime.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.Depth); } catch(Exception ex) { MessageBox.Show("Could not open depth stream: " + ex.Message); } }
public InputHandler(GraphicsDeviceManager graphicsManager) { graphics = graphicsManager; #if !XBOX360 // Enable && initialize Kinect if (KinectSensor.KinectSensors.Count > 0) { sensor = KinectSensor.KinectSensors[0]; if (sensor.Status == KinectStatus.Connected) { TransformSmoothParameters parameters = new TransformSmoothParameters { Smoothing = 0.5f, Correction = 0.5f, Prediction = 0.4f, JitterRadius = .2f, MaxDeviationRadius = 0.1f }; sensor.SkeletonStream.Enable(parameters); //sensor.SkeletonStream.Enable(); } sensor.Start(); } #endif }
private void Window_Loaded(object sender, RoutedEventArgs e) { this.DataContext = objects.VAL; sourceFrame.Source = new Uri("mainpage.xaml", UriKind.Relative); speaker.Rate = 0; speaker.Volume = 100; speaker.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Teen); Prompt spStatus = speaker.SpeakAsync(("Welcome. Using your right hand, swipe across, and touch a head, to continue.")); if (KinectSensor.KinectSensors.Count > 0) { purpleSensor = KinectSensor.KinectSensors[0]; } var parameters = new TransformSmoothParameters { Smoothing = 0.3f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; purpleSensor.SkeletonStream.Enable(parameters); purpleSensor.AllFramesReady += new EventHandler <AllFramesReadyEventArgs>(purpleSensor_AllFramesReady); purpleSensor.Start(); }
public MainWindow() { InitializeComponent(); var smoothing = new TransformSmoothParameters { Smoothing = 0.2f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; //Runtime initialization is handled when the window is opened. When the window this.WindowState = System.Windows.WindowState.Maximized; //Maximazes the Window Screen_Width = Convert.ToInt32(System.Windows.SystemParameters.PrimaryScreenWidth); Screen_Height = Convert.ToInt32(System.Windows.SystemParameters.PrimaryScreenHeight); LeftFoot.setX(0); LeftFoot.setZ(0); Half_Screen_Width = Screen_Width / 2; Half_Screen_Height = Screen_Height / 2; ScreenW.Text = Convert.ToString(Half_Screen_Width); ScreenH.Text = Convert.ToString(Half_Screen_Height); SetCursorPos(Half_Screen_Width, Half_Screen_Height);//To set the Cursor at the Build time at the center of the Screen //is closed, the runtime MUST be unitialized. //this.Loaded += new RoutedEventHandler(MainWindow_Loaded); //this.Unloaded += new RoutedEventHandler(MainWindow_Unloaded); //sensor.ColorStream.Enable(); //sensor.SkeletonStream.Enable(smoothing);//Uses the Smoothing Param. VX.Text = ""; VY.Text = ""; VZ.Text = ""; buttonText.Text = ""; }
public void Update(Joint[] joints) { //Check for divide by zero. Use an epsilon of a 10th of a millimeter m_fJitterRadius = Math.Max(0.0001f, m_fJitterRadius); TransformSmoothParameters SmoothingParams = new TransformSmoothParameters(); foreach (var joint in joints) { SmoothingParams.fSmoothing = m_fSmoothing; SmoothingParams.fCorrection = m_fCorrection; SmoothingParams.fPrediction = m_fPrediction; SmoothingParams.fJitterRadius = m_fJitterRadius; SmoothingParams.fMaxDeviationRadius = m_fMaxDeviationRadius; // If inferred, we smooth a bit more by using a bigger jitter radius if (joint.TrackingState == TrackingState.Inferred) { SmoothingParams.fJitterRadius *= 2.0f; SmoothingParams.fMaxDeviationRadius *= 2.0f; } Update(joint, SmoothingParams); } }
public MainWindow() { InitializeComponent(); var smoothing = new TransformSmoothParameters { Smoothing = 0.2f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; //Runtime initialization is handled when the window is opened. When the window this.WindowState = System.Windows.WindowState.Maximized;//Maximazes the Window Screen_Width =Convert.ToInt32(System.Windows.SystemParameters.PrimaryScreenWidth); Screen_Height = Convert.ToInt32(System.Windows.SystemParameters.PrimaryScreenHeight); LeftFoot.setX(0); LeftFoot.setZ(0); Half_Screen_Width = Screen_Width/2; Half_Screen_Height = Screen_Height/2; ScreenW.Text = Convert.ToString(Half_Screen_Width); ScreenH.Text = Convert.ToString(Half_Screen_Height); SetCursorPos(Half_Screen_Width,Half_Screen_Height);//To set the Cursor at the Build time at the center of the Screen //is closed, the runtime MUST be unitialized. //this.Loaded += new RoutedEventHandler(MainWindow_Loaded); //this.Unloaded += new RoutedEventHandler(MainWindow_Unloaded); //sensor.ColorStream.Enable(); //sensor.SkeletonStream.Enable(smoothing);//Uses the Smoothing Param. VX.Text = ""; VY.Text = ""; VZ.Text = ""; buttonText.Text= ""; }
public FreePlayKinectModel(Stream fileStream) : base() { Messenger.Default.Register<ShuttingDownMessage>(this, (message) => OnShuttingDown(message)); if (fileStream != null) { this.fileStream = fileStream; isRecorder = true; recorder.Start(fileStream); } if (Runtime.Kinects.Count > 0) { this.runtime = Runtime.Kinects[0]; this.runtime.Initialize(RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor | RuntimeOptions.UseDepthAndPlayerIndex); this.runtime.SkeletonEngine.TransformSmooth = true; TransformSmoothParameters parameters = new TransformSmoothParameters(); // parameters used to smooth the skeleton data parameters.Smoothing = 0.3f; parameters.Correction = 0.3f; parameters.Prediction = 0.4f; parameters.JitterRadius = 0.7f; parameters.MaxDeviationRadius = 0.2f; this.runtime.SkeletonEngine.SmoothParameters = parameters; this.runtime.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(SkeletonFrameReady); } }
private void InitKinectSensor() { // validate if (KinectSensor.KinectSensors.Count == 0) { return; } // init Kinect var parameters = new TransformSmoothParameters { Smoothing = 0.75f, Correction = 0.1f, Prediction = 0.0f, JitterRadius = 0.05f, MaxDeviationRadius = 0.08f }; _sensor = KinectSensor.KinectSensors[0]; _sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); _sensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30); _sensor.SkeletonStream.Enable(parameters); _sensor.Start(); colorViewer.Kinect = _sensor; skeletonViewer.Kinect = _sensor; _sensor.SkeletonFrameReady += SensorSkeletonFrameReady; }
//Methode d'initialisation public void initializ() { //on associe a port , le port USB COM3 port = new SerialPort ("COM3", 9600); //On ouvre le port pour l'envoie des données port.Open (); //On recupere la Kinect sensor = KinectSensor.KinectSensors[0]; // SmoothParamater pour reduire les interferances sur le SkeletonStream TransformSmoothParameters parameters = new TransformSmoothParameters{ Smoothing = 0.3f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; //On demare la capture sensor.Start(); // Ouverture des flux sensor.ColorStream.Enable(); sensor.DepthStream.Enable(); sensor.SkeletonStream.Enable(parameters); //on ouvre une frame toute les 33 millisecondes //soit environ 30 images secondes. sensor.SkeletonStream.OpenNextFrame(33); //le Tracking du skelette est réalisé par défault: //20 joints , quelque soit la position de l'utilisateur. sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Default; return; }
private bool RunKinect() { _kinect = KinectSensor.KinectSensors.Where(s => s.Status == KinectStatus.Connected).FirstOrDefault(); if (_kinect != null) { TransformSmoothParameters smoothingParam = new TransformSmoothParameters(); { smoothingParam.Smoothing = Convert.ToSingle(textBox_smoothing.Text); smoothingParam.Correction = Convert.ToSingle(textBox_correction.Text); smoothingParam.Prediction = Convert.ToSingle(textBox_prediction.Text); smoothingParam.JitterRadius = Convert.ToSingle(textBox_jitterRadius.Text); smoothingParam.MaxDeviationRadius = Convert.ToSingle(textBox_maxDeviationRadius.Text); }; _kinect.ColorStream.Enable(ColorStreamFormat); _kinect.DepthStream.Enable(DepthStreamFormat); _kinect.SkeletonStream.Enable(smoothingParam); _kinect.AllFramesReady += Kinect_AllFramesReady; _kinect.Start(); _kinect.ElevationAngle = KinectElevationAngle; return(true); } else { return(false); } }
private void InsRuntime() { runtime.SkeletonStream.Enable(); runtime.Start(); //VoiceCmder.Start(runtime); //CreateSpeechRecognizer(); //StartSpeechRecognition(); //var t = new Thread(new ThreadStart(RunKinectAudio)); //t.SetApartmentState(ApartmentState.MTA); //t.Start(); #region Smoothing var parameters = new TransformSmoothParameters { Smoothing = 0.4f, Correction = 0.1f, Prediction = 0.1f, JitterRadius = 0.4f, MaxDeviationRadius = 0.5f }; runtime.SkeletonStream.Enable(parameters); #endregion }
void kinectSensorChooser1_KinectSensorChanged(object sender, DependencyPropertyChangedEventArgs e) { KinectSensor old = (KinectSensor)e.OldValue; StopKinect(old); KinectSensor sensor = (KinectSensor)e.NewValue; if (sensor == 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); //sensor.SkeletonStream.Enable(); sensor.AllFramesReady += new EventHandler <AllFramesReadyEventArgs>(sensor_AllFramesReady); sensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); try { sensor.Start(); } catch (System.IO.IOException) { kinectSensorChooser1.AppConflictOccurred(); } }
void kinectSensorChooser_KinectSensorChanged(object sender, DependencyPropertyChangedEventArgs e) { KinectSensor old = (KinectSensor)e.OldValue; StopKinect(old); KinectSensor sensor = (KinectSensor)e.NewValue; if (sensor == null) { return; } TransformSmoothParameters parameters = new TransformSmoothParameters(); parameters.Smoothing = 0.7f; parameters.Correction = 0.3f; parameters.Prediction = 0.4f; parameters.JitterRadius = 1.0f; parameters.MaxDeviationRadius = 0.5f; sensor.SkeletonStream.Enable(parameters); sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); sensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30); sensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(sensor_AllFramesReady); try { sensor.Start(); } catch (System.IO.IOException) { //another app is using Kinect kinectSensorChooser.AppConflictOccurred(); } }
private void startKinect() { if (KinectSensor.KinectSensors.Count > 0) { // Choose the first Kinect device kinect = KinectSensor.KinectSensors[0]; if (kinect == null) return; kinect.ColorStream.Enable(); var tsp = new TransformSmoothParameters { Smoothing = 0.5f, Correction = 0.5f, Prediction = 0.5f, JitterRadius = 0.05f, MaxDeviationRadius = 0.04f }; kinect.SkeletonStream.Enable(tsp); // Start skeleton tracking //kinect.ColorFrameReady += new EventHandler<ColorImageFrameReadyEventArgs>(kinect_ColorFrameReady); //kinect.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(kinect_SkeletonFrameReady); // Start Kinect device kinect.Start(); } else { MessageBox.Show("No Kinect Device found."); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { // Sisteme Kinect bağlıysa, ilk Kinect'i yapılandır if (KinectSensor.KinectSensors.Count > 0) { KinectSensor.KinectSensors[0].Start(); // Renkli görüntü KinectSensor.KinectSensors[0].ColorStream.Enable (ColorImageFormat.RgbResolution1280x960Fps12); KinectSensor.KinectSensors[0].ColorFrameReady += new EventHandler <ColorImageFrameReadyEventArgs>(Kinect_ColorFrameReady); // İskelet verisi TransformSmoothParameters tsp = new TransformSmoothParameters(); tsp.Smoothing = 0.55f; tsp.Correction = 0.1f; tsp.Prediction = 0.1f; tsp.JitterRadius = 0.4f; tsp.MaxDeviationRadius = 0.4f; KinectSensor.KinectSensors[0].SkeletonStream.Enable(tsp); KinectSensor.KinectSensors[0].SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(Kinect_SkeletonFrameReady); } }
public void StartKinectSensor() { kinect = KinectSensor.KinectSensors[0]; if (kinect.Status == KinectStatus.Connected) { kinect.SkeletonStream.Enable(); kinect.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated; TransformSmoothParameters smoothingParam = new TransformSmoothParameters(); { smoothingParam.Smoothing = 0.5f; smoothingParam.Correction = 0.1f; smoothingParam.Prediction = 0.5f; smoothingParam.JitterRadius = 0.1f; smoothingParam.MaxDeviationRadius = 0.1f; }; kinect.SkeletonStream.Enable(smoothingParam); // Enable skeletal tracking skeletonData = new Skeleton[kinect.SkeletonStream.FrameSkeletonArrayLength]; kinect.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(kinect_SkeletonFrameReady); kinect.Start(); } else Console.WriteLine("No Kinect Found"); }
public static void SetSmoothParameters(TransformSmoothParameters value) { _correction = value.Correction; _jitterRadius = value.JitterRadius; _maxDeviationRadius = value.MaxDeviationRadius; _prediction = value.Prediction; _smoothing = value.Smoothing; }
public void EnableSkeletonStream() { TransformSmoothParameters parameters = new TransformSmoothParameters(); parameters.Correction = 0.1f; parameters.JitterRadius = 1.0f; parameters.MaxDeviationRadius = 0.2f; _sensor.SkeletonStream.Enable(parameters); }