public JointType isGestureActive(KinectUser user, PointQueue queue) { KinectDataPoint handLeft = getSekeltonService().getDataPoint(JointType.HandLeft, user); KinectDataPoint handRight = getSekeltonService().getDataPoint(JointType.HandRight, user); KinectDataPoint head = getSekeltonService().getDataPoint(JointType.Head, user); if (null != handLeft && null != handRight && null != head) { JointType? result = null; if (handLeft.Y > head.Y && handRight.Y > head.Y) { result = null; } else if (handLeft.Y > head.Y && handLeft.ScreenY < handRight.ScreenY) { result = JointType.HandRight; } else if (handRight.Y > head.Y && handRight.ScreenY < handLeft.ScreenY) { result = JointType.HandLeft; } if (null != result) { if (null == LastActiveUser || user != LastActiveUser) { LastActiveUser = user; queue.GetQueue(result.Value); } return result.Value; } } // if the last user is not active anymore -> set lastActiveUser to null if (null != LastActiveUser && user == LastActiveUser.Value) { LastActiveUser = null; } return default(JointType); }
private void initialize(KinectSensor sensor) { this.sensor = sensor; userDetector = new UserDetector(sensor); waveDetector = new WaveDetector(IConsts.GestureQueueSizeWave); swipeDetector = new SwipeDetector(IConsts.GestureQueueSizeSwipe); circleDetector = new CircleDetector(IConsts.GestureQueueSizeCycle); pushPullDetector = new PushPullGestureDetector(IConsts.GestureQueueSizePush); foreach (KinectUser user in Enum.GetValues(typeof(KinectUser))) { dataPointMap[user] = new PointQueue(IConsts.GestureQueueSize); } }