This class is the topmost gesture state class. There should only be one of these instantiated per active user. There is a dictionary in the form1 class that matches this information to an active user Skeleton Id.
Ejemplo n.º 1
0
 private void registerGestureControllerStates(GestureMapState state)
 {
     state.RegisterGestureResult(x => SendEventThroughPipe( ViCharConversion.GestureToByte( (ViCharGesture)x ) ) );
 }
Ejemplo n.º 2
0
        void SensorSkeletonFrameReady(AllFramesReadyEventArgs e)
        {
            using (SkeletonFrame skeletonFrameData = e.OpenSkeletonFrame())
            {
                if (skeletonFrameData == null)
                {
                    return;
                }

                var allSkeletons = new Skeleton[skeletonFrameData.SkeletonArrayLength];
                skeletonFrameData.CopySkeletonDataTo(allSkeletons);

                foreach (Skeleton sd in allSkeletons)
                {
                    // If this skeleton is no longer being tracked, skip it
                    if (sd.TrackingState != SkeletonTrackingState.Tracked)
                    {
                        continue;
                    }

                    // If there is not already a gesture state map for this skeleton, then create one
                    if (!_gestureMaps.ContainsKey(sd.TrackingId))
                    {
                        var mapstate = new GestureMapState(_gestureMap);
                        _gestureMaps.Add(sd.TrackingId, mapstate);
                    }

                    var keycode = _gestureMaps[sd.TrackingId].Evaluate(sd, false, _bitmap.Width, _bitmap.Height);
                    GetWaitingMessages(_gestureMaps);

                    if (keycode != VirtualKeyCode.NONAME)
                    {
                        rtbMessages.AppendText("Gesture accepted from player " + sd.TrackingId + "\r");
                        rtbMessages.ScrollToCaret();
                        rtbMessages.AppendText("Command passed to System: " + keycode + "\r");
                        rtbMessages.ScrollToCaret();
                        InputSimulator.SimulateKeyPress(keycode);
                        _gestureMaps[sd.TrackingId].ResetAll(sd);
                    }

                    // This break prevents multiple player data from being confused during evaluation.
                    // If one were going to dis-allow multiple players, this trackingId would facilitate
                    // that feat.
                    PlayerId = sd.TrackingId;

                    if (_bitmap != null)
                        _bitmap = AddSkeletonToDepthBitmap(sd, _bitmap, true);

                }
            }
        }
Ejemplo n.º 3
0
        void SensorSkeletonFrameReady(AllFramesReadyEventArgs e)
        {
            using (SkeletonFrame skeletonFrameData = e.OpenSkeletonFrame())
            {
                if (skeletonFrameData == null)
                {
                    return;
                }

                var allSkeletons = new Skeleton[skeletonFrameData.SkeletonArrayLength];
                skeletonFrameData.CopySkeletonDataTo(allSkeletons);

                foreach (Skeleton sd in allSkeletons)
                {
                    // If this skeleton is no longer being tracked, skip it
                    if (sd.TrackingState != SkeletonTrackingState.Tracked)
                    {
                        continue;
                    }

                    // If there is not already a gesture state map for this skeleton, then create one
                    if (!_gestureMaps.ContainsKey(sd.TrackingId))
                    {
                        var mapstate = new GestureMapState(_gestureMap);
                        _gestureMaps.Add(sd.TrackingId, mapstate);
                    }

                    var keycode = _gestureMaps[sd.TrackingId].Evaluate(sd, false, _bitmap.Width, _bitmap.Height);
                    GetWaitingMessages(_gestureMaps);

                    if (keycode != VirtualKeyCode.NONAME)
                    {
                        //Another method
                        //InputSimulator.SimulateKeyPress(keycode);

                        switch (keycode)
                        {
                            case VirtualKeyCode.RBUTTON:
                                p.DoPunch(Direction.Right);
                                break;
                            case VirtualKeyCode.LBUTTON:
                                p.DoPunch(Direction.Left);
                                break;
                            default:
                                break;
                        }

                        _gestureMaps[sd.TrackingId].ResetAll(sd);
                    }

                    p.SetPosition(new Vector2(sd.Joints[JointType.HipCenter].Position.X, p.pos.Y));

                    // This break prevents multiple player data from being confused during evaluation.
                    // If one were going to dis-allow multiple players, this trackingId would facilitate
                    // that feat.
                    PlayerId = sd.TrackingId;

                    if (_bitmap != null)
                        _bitmap = AddSkeletonToDepthBitmap(sd, _bitmap, true);
                }
            }
        }
Ejemplo n.º 4
0
        private bool CompareJointRelationship(Joint inJoint1, Joint inJoint2, JointRelationship relation)
        {
            if ((inJoint1.JointType.ToString().Contains("WristRight")))
            {
                if (inJoint2.JointType.ToString().Contains("ShoulderCenter"))
                {
                    sizeOfArm = inJoint2.Position.Z - inJoint1.Position.Z;
                    if ((sizeOfArm > 0.5) && (!gest))
                    {
                        gest = true;
                        Debug.WriteLine("Arm Size:" + sizeOfArm.ToString());
                        Debug.WriteLine("Forward Gesture Detected: " + gest);
                        GestureMapState.Connect("169.254.27.218", 4);
                    }
                    else
                    if ((sizeOfArm < 0.3) && (gest))
                    {
                        gest = false;
                    }
                }
            }
            if (inJoint2.JointType.ToString().Contains("WristRight"))
            {
                Debug.WriteLine("Posicao da junta " + inJoint2.JointType + " #2 em Z: " + inJoint2.Position.Z);
            }

            switch (relation)
            {
            case JointRelationship.None:
                return(true);

            case JointRelationship.AboveAndLeft:
                return((inJoint1.Position.X < inJoint2.Position.X) && (inJoint1.Position.Y < inJoint2.Position.Y));

            case JointRelationship.AboveAndRight:
                return((inJoint1.Position.X > inJoint2.Position.X) && (inJoint1.Position.Y < inJoint2.Position.Y));

            case JointRelationship.BelowAndLeft:
                return((inJoint1.Position.X < inJoint2.Position.X) && (inJoint1.Position.Y > inJoint2.Position.Y));

            case JointRelationship.BelowAndRight:
                return((inJoint1.Position.X > inJoint2.Position.X) && (inJoint1.Position.Y > inJoint2.Position.Y));

            case JointRelationship.Behind:
                return((inJoint1.Position.Z < inJoint2.Position.Z));

            case JointRelationship.InFrontOf:
                return((inJoint1.Position.Z > inJoint2.Position.Z));

            case JointRelationship.Below:
                return(inJoint1.Position.Y > inJoint2.Position.Y);

            case JointRelationship.Above:
                return(inJoint1.Position.Y < inJoint2.Position.Y);

            case JointRelationship.LeftOf:
                return(inJoint1.Position.X < inJoint2.Position.X);

            case JointRelationship.RightOf:
                return(inJoint1.Position.X > inJoint2.Position.X);
            }
            return(false);
        }