//
 private void UpdateChecking()
 {
     if (!this.Checking)
     {
         this.groundTruthUnifiedSkeleton = null;
     }
 }
        private void CompareSkeleton()
        {
            if (this.groundTruthSkeleton != null && this.groundTruthUnifiedSkeleton == null)
            {
                this.groundTruthUnifiedSkeleton = new UnifiedSkeleton(this.groundTruthSkeleton);
            }

            this.playerUnifiedSkeleton = new UnifiedSkeleton(this.selectedSkeleton);
        }
示例#3
0
        /// <summary>
        /// Handler for rendering Kinect data
        /// </summary>
        private void OnKinectDataReady(object sender, EventArgs e)
        {
            if (this.sensorManager != null)
            {
                if (null == this.kinectSkeleton)
                {
                    this.kinectSkeleton = new KinectSkeleton(this.sensorManager.Sensor.CoordinateMapper);
                }
                if (this.sensorManager.PStatus == PlayingStatus.Playing)
                {
                    if (this.ssc == null)
                    {
                        this.ssc = new SkeletonStreamComparer(this.sensorManager.RecordingUnifiedSkeletons, this.sensorManager.UseWeight);
                    }

                    if (this.playingIndex < this.sensorManager.RecordingSkeletons.Count)
                    {
                        this.kinectSkeleton.DrawSkeleton(this.sensorManager.RecordingSkeletons[this.playingIndex], this.kinectImage);
                    }
                    this.playingIndex++;
                }
                else
                {
                    this.ssc          = null;
                    this.playingIndex = 0;
                    RenderingHelper.WriteColorFrameToBitmap(
                        this.sensorManager.ImagePixels,
                        this.sensorManager.ColorWidth,
                        this.sensorManager.ColorHeight,
                        ref this.colorFrameBitmap);
                    this.kinectSkeleton.DrawSkeletonOnColorImage(
                        this.sensorManager.PStatus == PlayingStatus.Recording ? this.sensorManager.SelectedSkeleton : this.sensorManager.GroundTruchSkeleton,
                        this.colorFrameBitmap,
                        this.kinectImage);
                }

                // Render the player skeleton
                if (null == this.playerSkeleton)
                {
                    this.playerSkeleton = new KinectSkeleton(this.sensorManager.Sensor.CoordinateMapper);
                }
                this.playerSkeleton.DrawSkeleton(
                    this.sensorManager.SelectedSkeleton,
                    this.skeletonImage);

                //
                if (this.sensorManager.PStatus == PlayingStatus.Recording)
                {
                    this.functionSettings.Status = "Recording frames " + this.sensorManager.RecordingSkeletons.Count.ToString();
                }
                else if (this.sensorManager.PStatus == PlayingStatus.Playing)
                {
                    this.ssc.Update(new UnifiedSkeleton(this.sensorManager.SelectedSkeleton), this.playingIndex - 1);

                    this.functionSettings.Status = "Score " + this.ssc.Score.ToString();
                }
                else if (this.sensorManager.Checking && this.sensorManager.GroundTruthUnifiedSkeleton != null &&
                         this.sensorManager.GroundTruthUnifiedSkeleton.IsValid)
                {
                    JointType     joint = this.functionSettings.BoneJoint;
                    StringBuilder sb    = new StringBuilder();
                    sb.Append(UnifiedSkeleton.ComputeDistance(this.sensorManager.GroundTruthUnifiedSkeleton, this.sensorManager.PlayerUnifiedSkeleton) + " ");
                    sb.Append(this.sensorManager.GroundTruthUnifiedSkeleton.Bones[joint].NormalizedBone + " ");
                    Vector3D vec = new Vector3D(0, 0, 0);
                    if (this.sensorManager.PlayerUnifiedSkeleton.IsValid)
                    {
                        sb.Append(this.sensorManager.PlayerUnifiedSkeleton.Bones[joint].NormalizedBone + " ");
                        vec = this.sensorManager.PlayerUnifiedSkeleton.Bones[joint].NormalizedBone;
                    }
                    else
                    {
                        sb.Append(vec + " ");
                    }
                    sb.Append(Vector3D.Distance(this.sensorManager.GroundTruthUnifiedSkeleton.Bones[joint].NormalizedBone, vec).ToString("0.000"));

                    this.functionSettings.Status = sb.ToString();
                }
            }
        }