void SaveStartPositions()
    {
        Astra.Body body         = skeletonViewer.Bodies[0];
        var        rightHandPos = body.Joints[7].WorldPosition; //transform to local Position!!

        jointPositions[7] = new Vector3(rightHandPos.X / 1000f, rightHandPos.Y / 1000f, rightHandPos.Z / 1000f);
        var rightEllbowPos = body.Joints[6].WorldPosition; //transform to local Position!!

        jointPositions[6] = new Vector3(rightEllbowPos.X / 1000f, rightEllbowPos.Y / 1000f, rightEllbowPos.Z / 1000f);
        var rightShoulderPos = body.Joints[5].WorldPosition; //transform to local Position!!

        jointPositions[5] = new Vector3(rightShoulderPos.X / 1000f, rightShoulderPos.Y / 1000f, rightShoulderPos.Z / 1000f);

        // route gestreckter Arm, von nach unten hängen, gestreckt bis gerade nach oben
        //distance zwischen hand/ellenbogen/schulter soll gleich bleiben, anderer winkel! --> kein x movement?
        distHandEllbow     = Vector3.Distance(jointPositions[7], jointPositions[6]);
        distEllbowShoulder = Vector3.Distance(jointPositions[6], jointPositions[5]);
        distHandShoulder   = Vector3.Distance(jointPositions[7], jointPositions[5]);



        //more positions:

        /*
         * positions[0] = new Vector3(jointPositions[5].x, jointPositions[7].y, jointPositions[7].z);
         * positions[1] = new Vector3(jointPositions[5].x, jointPositions[7].y + distHandEllbow, jointPositions[7].z - distHandEllbow);
         * positions[2] = new Vector3(jointPositions[5].x, jointPositions[5].y, jointPositions[5].z - distHandShoulder);
         * positions[3] = new Vector3(jointPositions[5].x, jointPositions[5].y + distHandEllbow, jointPositions[5].z - distHandEllbow);
         * positions[4] = new Vector3(jointPositions[5].x, jointPositions[5].y + distHandShoulder, jointPositions[7].z);
         *
         * SpawnRoute();
         */
    }
Exemple #2
0
        // Draws joint as circle
        private void DrawJoints(DrawingContext dc, Astra.Body body)
        {
            foreach (var joint in body.Joints)
            {
                if (IsJointOk(joint))
                {
                    var isTracked = joint.Status == Astra.JointStatus.Tracked;

                    var brush = isTracked
                        ? TrackedJointFill
                        : LowConfidenceJointFill;

                    var radius = isTracked
                        ? TrackedJointCircleRadius
                        : LowConfidenceJointCircleRadius;

                    dc.DrawEllipse(brush, JointBorder, ToImagePoint(joint), radius, radius);

                    // Show label with 3D coordinates only for one spine joint.
                    // You can remove the following "if"-statement, in case you want to see labels with 3D coordinates for all joints.
                    if (joint.Type == Astra.JointType.RightHand)
                    {
                        DrawJointLabel(dc, joint, radius);
                    }
                    if (joint.Type == Astra.JointType.LeftHand)
                    {
                        DrawJointLabel(dc, joint, radius);
                    }
                    getGesture(joint); //dkdkdkdk
                }
            }
        }
Exemple #3
0
 private static int FindJointIndex(Astra.Body body, Astra.JointType jointType)
 {
     for (int i = 0; i < body.Joints.Length; i++)
     {
         if (body.Joints[i].Type == jointType)
         {
             return(i);
         }
     }
     return(-1);
 }
    void ShoulderYX()
    {
        Astra.Body body         = skeletonViewer.Bodies[0];
        var        rightHandPos = body.Joints[7].WorldPosition; //transform to local Position!!
        var        jointPos     = new Vector3(rightHandPos.X / 1000f, rightHandPos.Y / 1000f, rightHandPos.Z / 1000f);

        if (Vector3.Distance(new Vector3(0, 0, jointPos.z), new Vector3(0, 0, jointPositions[7].z)) > 0.15f)
        {
            //Debug.Log("uffbassa! YX");
            //thalmicMyo.Vibrate(VibrationType.Short);
        }
    }
Exemple #5
0
        /// <summary>
        /// Creates visualizer. Call from UI thread because during construction <c>ImageSource</c> is being created.
        /// </summary>
        /// <param name="dispatcher">Dispatcher of owner thread. As a rule, UI thread.</param>
        /// <param name="depthWidth">Width of depth map.</param>
        /// <param name="depthHeight">Height of depth map.</param>
        public BodyVisualizer(Dispatcher dispatcher, int depthWidth, int depthHeight)
        {
            if (dispatcher.Thread != Thread.CurrentThread)
            {
                throw new InvalidOperationException(
                          "Call this constructor from UI thread please, because it creates ImageSource object for UI");
            }

            this.dispatcher  = dispatcher;
            this.depthWidth  = depthWidth;
            this.depthHeight = depthHeight;

            // Astra SDK supports up to 6 bodies
            bodies = new Astra.Body[6];

            // WPF stuff to draw skeleton
            drawingGroup = new DrawingGroup
            {
                ClipGeometry = new RectangleGeometry(new Rect(0, 0, depthWidth, depthHeight)),
            };
            ImageSource = new DrawingImage(drawingGroup);
        }
Exemple #6
0
        // Draws bone as line (stick) between two joints
        private void DrawBones(DrawingContext dc, Astra.Body body)
        {
            foreach (var bone in bones)
            {
                var parentJoint = FindJoint(body, bone.ParentJointType);
                if (IsJointOk(parentJoint))
                {
                    var endJoint = FindJoint(body, bone.EndJointType);
                    if (IsJointOk(endJoint))
                    {
                        var isTracked =
                            parentJoint.Status == Astra.JointStatus.Tracked &&
                            endJoint.Status == Astra.JointStatus.Tracked;

                        var pen = isTracked
                            ? TrackedBonePen
                            : LowConfidenceBonePen;

                        dc.DrawLine(pen, ToImagePoint(parentJoint), ToImagePoint(endJoint));
                    }
                }
            }
        }
Exemple #7
0
 private static Astra.Joint FindJoint(Astra.Body body, Astra.JointType jointType)
 => body.Joints.FirstOrDefault(j => j.Type == jointType);
 public static bool IsBodyOk(Astra.Body body)
 => body != null && body.Status != Astra.BodyStatus.NotTracking;