private void DrawSkeletons(DrawingContext drawingContext)
        {
            foreach (Skeleton skeleton in this.skeletonData)
            {
                if (skeleton != null)
                {
                    if (skeleton.TrackingState == SkeletonTrackingState.Tracked)
                    {
                        DrawTrackedSkeletonJoints(skeleton.Joints, drawingContext);

                        //checkFor recording ideal posture
                        if (recordIdeal == true)
                        {
                            recordIdeal = false;
                            recordIdealPosture(skeleton);
                        }

                        //tutaj przetwarzanie katow itd HERE
                        updateCurrentPostureParams(skeleton);

                        WrongPostureClassifier.diagnozeWrongPosture(currentPostureParams);
                    }
                    else if (skeleton.TrackingState == SkeletonTrackingState.PositionOnly)
                    {
                        DrawSkeletonPosition(skeleton.Position, drawingContext);
                    }
                    RenderClippedEdges(skeleton, drawingContext);
                }
            }
        }
Ejemplo n.º 2
0
        private void SensorChooserOnKinectChanged(object sender, KinectChangedEventArgs kinectChangedEventArgs)
        {
            KinectSensor oldSensor = kinectChangedEventArgs.OldSensor;
            KinectSensor newSensor = kinectChangedEventArgs.NewSensor;

            if (oldSensor != null)
            {
                oldSensor.AllFramesReady -= KinectSensorOnAllFramesReady;
                oldSensor.ColorStream.Disable();
                oldSensor.DepthStream.Disable();
                oldSensor.DepthStream.Range = DepthRange.Default;
                oldSensor.SkeletonStream.Disable();
                oldSensor.SkeletonStream.EnableTrackingInNearRange = false;
                oldSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Default;
            }

            if (newSensor != null)
            {
                try
                {
                    newSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
                    newSensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
                    try
                    {
                        // This will throw on non Kinect For Windows devices.
                        newSensor.DepthStream.Range = DepthRange.Near;
                        newSensor.SkeletonStream.EnableTrackingInNearRange = true;
                    }
                    catch (InvalidOperationException)
                    {
                        newSensor.DepthStream.Range = DepthRange.Default;
                        newSensor.SkeletonStream.EnableTrackingInNearRange = false;
                    }

                    TransformSmoothParameters smoothingParameters = new TransformSmoothParameters();
                    {
                        smoothingParameters.Smoothing          = 0.5f;
                        smoothingParameters.Correction         = 0.5f;
                        smoothingParameters.Prediction         = 0.5f;
                        smoothingParameters.JitterRadius       = 0.05f;
                        smoothingParameters.MaxDeviationRadius = 0.04f;
                    }


                    newSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
                    newSensor.SkeletonStream.Enable(smoothingParameters);
                    newSensor.AllFramesReady += KinectSensorOnAllFramesReady;

                    WrongPostureClassifier.setRef(this);
                }
                catch (InvalidOperationException)
                {
                    // This exception can be thrown when we are trying to
                    // enable streams on a device that has gone away.  This
                    // can occur, say, in app shutdown scenarios when the sensor
                    // goes away between the time it changed status and the
                    // time we get the sensor changed notification.
                    //
                    // Behavior here is to just eat the exception and assume
                    // another notification will come along if a sensor
                    // comes back.
                }
            }
        }