0

This is the code I use to record the points that includes a few computations. So yep, I get the value locations of the point, do some math, then save them to a list.

gesture.L.E.AddFrameDescriptor(
    joints[JointType.ElbowLeft].Position.X, joints[JointType.ElbowLeft].Position.Y, joints[JointType.ElbowLeft].Position.Z,
    joints[JointType.SpineMid].Position.X, joints[JointType.SpineMid].Position.Y, joints[JointType.SpineMid].Position.Z,
    spineBaseShoulderRHO
    );
gesture.L.W.AddFrameDescriptor(
    joints[JointType.WristLeft].Position.X, joints[JointType.WristLeft].Position.Y, joints[JointType.WristLeft].Position.Z,
    joints[JointType.SpineMid].Position.X, joints[JointType.SpineMid].Position.Y, joints[JointType.SpineMid].Position.Z,
    spineBaseShoulderRHO
    );
gesture.L.H.AddFrameDescriptor(
    joints[JointType.HandTipLeft].Position.X, joints[JointType.HandTipLeft].Position.Y, joints[JointType.HandTipLeft].Position.Z,
    joints[JointType.SpineMid].Position.X, joints[JointType.SpineMid].Position.Y, joints[JointType.SpineMid].Position.Z,
    spineBaseShoulderRHO
    );


gesture.R.E.AddFrameDescriptor(
    joints[JointType.ElbowRight].Position.X, joints[JointType.ElbowRight].Position.Y, joints[JointType.ElbowRight].Position.Z,
    joints[JointType.SpineMid].Position.X, joints[JointType.SpineMid].Position.Y, joints[JointType.SpineMid].Position.Z,
    spineBaseShoulderRHO
    );
gesture.R.W.AddFrameDescriptor(
    joints[JointType.WristRight].Position.X, joints[JointType.WristRight].Position.Y, joints[JointType.WristRight].Position.Z,
    joints[JointType.SpineMid].Position.X, joints[JointType.SpineMid].Position.Y, joints[JointType.SpineMid].Position.Z,
    spineBaseShoulderRHO
    );
gesture.R.H.AddFrameDescriptor(
    joints[JointType.HandTipRight].Position.X, joints[JointType.HandTipRight].Position.Y, joints[JointType.HandTipRight].Position.Z,
    joints[JointType.SpineMid].Position.X, joints[JointType.SpineMid].Position.Y, joints[JointType.SpineMid].Position.Z,
    spineBaseShoulderRHO
    );

For some reason I get a lot of repeated values, repeated for like 20 times. I've noticed if I saved only a single value, I get significant values and no more repetitions, plus the difference of the values are much closer to each other like 0.05513 then 0.05413 compared to those repeated once I get like twenty 0.05513 then the next is twenty 0.05013.

EDIT Here is the sample values I get if I store multiple values to a list.

0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.399695181 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401078759 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401423597 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625 0.401669625

As you can see the numbers are repeated like twenty times.

EXTENDED CODE

private void DrawBody(IReadOnlyDictionary<JointType, Joint> joints, IDictionary<JointType, Point> jointPoints, DrawingContext drawingContext, Pen drawingPen)
    {
        foreach (var bone in this.bones)
        {
            this.DrawBone(joints, jointPoints, bone.Item1, bone.Item2, drawingContext, drawingPen);
        }

        foreach (JointType jointType in joints.Keys)
        {
            if (!(jointType.Equals(JointType.HandLeft) || jointType.Equals(JointType.HandRight) || jointType.Equals(JointType.ThumbLeft) || jointType.Equals(JointType.ThumbRight)))
            {
                Brush drawBrush = null;

                TrackingState trackingState = joints[jointType].TrackingState;

                if (trackingState == TrackingState.Tracked)
                {
                    drawBrush = this.trackedJointBrush;

                    check.Add(joints[JointType.ElbowLeft].Position.X);
                    if (this.status_active)
                    {
                        if (!this.status_ready && (new MathFunctions().GetDist2P(joints[JointType.HandTipLeft].Position.X, joints[JointType.HandTipRight].Position.X) <= 0.03 && joints[JointType.HandTipLeft].Position.Y < joints[JointType.SpineMid].Position.Y && joints[JointType.HandTipRight].Position.Y < joints[JointType.SpineMid].Position.Y))
                        {
                            lbl_status.Content = "READY"; lbl_status.Foreground = Brushes.Green; ellps_status.Fill = Brushes.Green;
                            this.status_ready = true;
                        }

                        else if (this.status_ready)
                        {
                            if (!this.status_recording && (joints[JointType.HandTipLeft].Position.Y > joints[JointType.SpineBase].Position.Y || joints[JointType.HandTipRight].Position.Y > joints[JointType.SpineBase].Position.Y))
                            {
                                lbl_status.Content = "RECORDING"; lbl_status.Foreground = Brushes.Red; ellps_status.Fill = Brushes.Red;
                                this.status_recording = true;

                                this.gesture = new Gesture();

                                spineBaseShoulderRHO = new MathFunctions().GetRho(
                                                                new MathFunctions().GetDist2P(joints[JointType.SpineBase].Position.X, joints[JointType.SpineShoulder].Position.X),
                                                                new MathFunctions().GetDist2P(joints[JointType.SpineBase].Position.Y, joints[JointType.SpineShoulder].Position.Y),
                                                                new MathFunctions().GetDist2P(joints[JointType.SpineBase].Position.Z, joints[JointType.SpineShoulder].Position.Z)
                                    );
                            }

                            else if (status_recording)
                            {
                                if (joints[JointType.HandTipLeft].Position.Y < joints[JointType.SpineBase].Position.Y && joints[JointType.HandTipRight].Position.Y < joints[JointType.SpineBase].Position.Y)
                                {
                                    lbl_status.Content = "ACTIVE"; lbl_status.Foreground = Brushes.Black; ellps_status.Fill = Brushes.Black;

                                    this.status_active = true;
                                    this.status_ready = false;
                                    this.status_recording = false;

                                    gesture = new SLFunctions().RemoveRedundantPoints(gesture);

                                    //  identify gesture
                                    if (tbox_word.Text == "")
                                    {
                                        SimilarityIndex minIndex = new SLFunctions().IdentifyGesture(library, gesture);

                                        lbl_word.Content = minIndex.gestureName;
                                    }

                                    //  new gesture
                                    else
                                    {
                                        gesture.name = tbox_word.Text;

                                        new SLFunctions().SaveGesture(gesture, "library");

                                        library.Add(gesture);

                                        tbox_word.Text = "";
                                    }
                                }
                                #region AddFrameDescriptor

                                gesture.L.E.AddFrameDescriptor(
                                    joints[JointType.ElbowLeft].Position.X, joints[JointType.ElbowLeft].Position.Y, joints[JointType.ElbowLeft].Position.Z,
                                    joints[JointType.SpineMid].Position.X, joints[JointType.SpineMid].Position.Y, joints[JointType.SpineMid].Position.Z,
                                    spineBaseShoulderRHO
                                    );
                                gesture.L.W.AddFrameDescriptor(
                                    joints[JointType.WristLeft].Position.X, joints[JointType.WristLeft].Position.Y, joints[JointType.WristLeft].Position.Z,
                                    joints[JointType.SpineMid].Position.X, joints[JointType.SpineMid].Position.Y, joints[JointType.SpineMid].Position.Z,
                                    spineBaseShoulderRHO
                                    );
                                gesture.L.H.AddFrameDescriptor(
                                    joints[JointType.HandTipLeft].Position.X, joints[JointType.HandTipLeft].Position.Y, joints[JointType.HandTipLeft].Position.Z,
                                    joints[JointType.SpineMid].Position.X, joints[JointType.SpineMid].Position.Y, joints[JointType.SpineMid].Position.Z,
                                    spineBaseShoulderRHO
                                    );


                                gesture.R.E.AddFrameDescriptor(
                                    joints[JointType.ElbowRight].Position.X, joints[JointType.ElbowRight].Position.Y, joints[JointType.ElbowRight].Position.Z,
                                    joints[JointType.SpineMid].Position.X, joints[JointType.SpineMid].Position.Y, joints[JointType.SpineMid].Position.Z,
                                    spineBaseShoulderRHO
                                    );
                                gesture.R.W.AddFrameDescriptor(
                                    joints[JointType.WristRight].Position.X, joints[JointType.WristRight].Position.Y, joints[JointType.WristRight].Position.Z,
                                    joints[JointType.SpineMid].Position.X, joints[JointType.SpineMid].Position.Y, joints[JointType.SpineMid].Position.Z,
                                    spineBaseShoulderRHO
                                    );
                                gesture.R.H.AddFrameDescriptor(
                                    joints[JointType.HandTipRight].Position.X, joints[JointType.HandTipRight].Position.Y, joints[JointType.HandTipRight].Position.Z,
                                    joints[JointType.SpineMid].Position.X, joints[JointType.SpineMid].Position.Y, joints[JointType.SpineMid].Position.Z,
                                    spineBaseShoulderRHO
                                    );
                                #endregion
                            }
                        }
                    }
                }

                else if (trackingState == TrackingState.Inferred)
                {
                    drawBrush = this.inferredJointBrush;
                }

                if (drawBrush != null)
                {
                    drawingContext.DrawEllipse(drawBrush, null, jointPoints[jointType], JointThickness, JointThickness);
                }
            }
        }
    }
  • I'm not sure if I understand your question, but note that you'll get the same values from the Kinect if you get the joint position data before it has a new skeleton frame. The skeleton frame comes with a timestamp, so if you save the same skeleton frame with the same timestamp, you'll get repeated values. You might want to clarify your question with examples of output data you are seeing, as well as other code that shows how you are calling the code you put in your question. – sonnyb May 14 '18 at 19:06
  • @sonny check out my additional information. Thanks. – SoupCode0169 May 15 '18 at 00:02
  • I find it's still not clear, e.g. where are the values actually being saved to a list? What does `AddFrameDescriptor` do? How does the code differ for the "save singe value" case vs. "save multiple values" case? See [this link MCVE which will likely help clarify your question](https://stackoverflow.com/help/mcve). What do the 20+ values you posted correspond to? If you don't know, as a suggestion I think you might want to change your code to also print labels next to the numbers just as a quick way to debug. Also, please respond to my previous comment to rule that out as a possible issue – sonnyb May 16 '18 at 18:56

0 Answers0