Beispiel #1
0
    void DrawLineBetweenJoints(OpenNI.SkeletonJoint first, OpenNI.SkeletonJoint second)
    {
        NISelectedPlayer player = playerSelection.GetPlayer(0);

        OpenNI.SkeletonJointPosition firstJointPosition;
        player.GetSkeletonJointPosition(first, out firstJointPosition);
        OpenNI.SkeletonJointPosition secondJointPosition;
        player.GetSkeletonJointPosition(second, out secondJointPosition);

        if (firstJointPosition.Confidence <= 0.5 || secondJointPosition.Confidence <= 0.5)
        {
            return;
        }

        OpenNI.Point3D firstJointScreenPosition  = depthGenerator.ConvertRealWorldToProjective(firstJointPosition.Position);
        OpenNI.Point3D secondJointScreenPosition = depthGenerator.ConvertRealWorldToProjective(secondJointPosition.Position);
        DrawLine.DrawSimpleLine(ref mapPixels,
                                (int)(width - firstJointScreenPosition.X / factor), (int)(height - firstJointScreenPosition.Y / factor),
                                (int)(width - secondJointScreenPosition.X / factor), (int)(height - secondJointScreenPosition.Y / factor),
                                width, height,
                                Color.white);
    }
        /// <summary>
        /// Converts a JointDictionary with 3D data to the corresponding one
        /// with 2D data. Note that the Z-Coordinate is left unchanged, though
        /// it has no meaning in the resulting 2D space and can be seen as 0.
        /// </summary>
        public JointDictionary Convert3Dto2D(JointDictionary source, DepthGenerator generator)
        {
            if (!source.Is3DData)
                return new JointDictionary(source);
            else
            {
                JointDictionary ret = new JointDictionary(false);

                foreach (SkeletonJoint joint in source.Keys)
                {
                    SkeletonJointPosition pos = new SkeletonJointPosition();
                    pos.Confidence = source[joint].Confidence;
                    pos.Position = generator.ConvertRealWorldToProjective(source[joint].Position);
                    ret.Add(joint, pos);
                }
                return ret;
            }
        }