diff --git a/ExplorVizGestureControl/Gestures/ContinuousGestureDetector.cs b/ExplorVizGestureControl/Gestures/ContinuousGestureDetector.cs index ace77ff86bcc9c22741f798b1d99efccf02f7956..5885dd4460f88132d13fbae7bd3f5f1f02d41e00 100644 --- a/ExplorVizGestureControl/Gestures/ContinuousGestureDetector.cs +++ b/ExplorVizGestureControl/Gestures/ContinuousGestureDetector.cs @@ -18,8 +18,7 @@ namespace ExplorVizGestureControl.Gestures public class ContinuousGestureDetector { #region Variables - private CoordinateMapper coordinateMapper = null; - private GestureDatabase gestureDatabase = null; + private CoordinateMapper coordinateMapper = null; [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] private static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo); @@ -68,14 +67,14 @@ namespace ExplorVizGestureControl.Gestures #endregion - public void DetectContinousGestures(GestureDatabase database) + public void DetectContinousGestures() { if (delayTimer.busy) return; - gestureDatabase = database; - handRight = gestureDatabase.handRight; - handLeft = gestureDatabase.handLeft; - phiz = gestureDatabase.phiz; + + handRight = GestureDatabase.handRight; + handLeft = GestureDatabase.handLeft; + phiz = GestureDatabase.phiz; // Detect and handle continuous gestures @@ -108,11 +107,11 @@ namespace ExplorVizGestureControl.Gestures { if (gripActive) return; - if (gestureDatabase.BothHandsParallel(2) && - gestureDatabase.BothHandsAboveSpineBase() && - gestureDatabase.RightHandBelowRightShoulder() && - gestureDatabase.LeftHandBelowLeftShoulder() && - gestureDatabase.BothHandsOpen()) + if (GestureDatabase.BothHandsParallel(2) && + GestureDatabase.BothHandsAboveSpineBase() && + GestureDatabase.RightHandBelowRightShoulder() && + GestureDatabase.LeftHandBelowLeftShoulder() && + GestureDatabase.BothHandsOpen()) { if (!rotationActive) { @@ -161,8 +160,8 @@ namespace ExplorVizGestureControl.Gestures { if (gripActive) return; - int scrollValue = 0; - double distance = gestureDatabase.spineBase.Z - gestureDatabase.oldSpineBase.Z; + int scrollValue = 0; + double distance = GestureDatabase.spineBase.Z - GestureDatabase.oldSpineBase.Z; //if (distance > dynamicValues["scrollForwardFactor"] || // distance < dynamicValues["scrollBackwardFactor"]) @@ -182,7 +181,7 @@ namespace ExplorVizGestureControl.Gestures private void HandleGripAndSelection() { - if (gestureDatabase.DragObject()) + if (GestureDatabase.DragObject()) { if (!gripActive) { diff --git a/ExplorVizGestureControl/Gestures/DiscreteGestureDetector.cs b/ExplorVizGestureControl/Gestures/DiscreteGestureDetector.cs index 1178678d51129beb816df6e19650b7d736703f92..776eb9cb546296bd810d978e89d5c51d82255df4 100644 --- a/ExplorVizGestureControl/Gestures/DiscreteGestureDetector.cs +++ b/ExplorVizGestureControl/Gestures/DiscreteGestureDetector.cs @@ -40,9 +40,9 @@ namespace ExplorVizGestureControl.Gestures #endregion #region Gesture recognition - public void gestureRecognition(GestureDatabase gestureDatabase) + public void gestureRecognition() { - foreach (KeyValuePair> entry in gestureDatabase.GestureDictionary) + foreach (KeyValuePair> entry in GestureDatabase.GestureDictionary) { if (entry.Value.Invoke() && !this.timerForNextGesture.busy) diff --git a/ExplorVizGestureControl/MainWindow.xaml.cs b/ExplorVizGestureControl/MainWindow.xaml.cs index 98dc10eb8e5030af2783e3c61e8a319d50f49279..6e79bac76713a3e5edfaf39f6c1fc84439fc34b5 100644 --- a/ExplorVizGestureControl/MainWindow.xaml.cs +++ b/ExplorVizGestureControl/MainWindow.xaml.cs @@ -30,8 +30,7 @@ namespace ExplorVizGestureControl private Body[] bodies; private BodyFrameReader bodyReader; - private ContinuousGestureDetector continuousGestureDetector; - private GestureDatabase gestureDatabase; + private ContinuousGestureDetector continuousGestureDetector; private DiscreteGestureDetector discreteGestureDetector; private KinectJointFilter filter = new KinectJointFilter(); @@ -69,8 +68,7 @@ namespace ExplorVizGestureControl FrameworkElement xamlElement = new FrameworkElement(); xamlElement.Style = (Style)this.FindResource("Stream"); - continuousGestureDetector = new ContinuousGestureDetector(); - gestureDatabase = new GestureDatabase(); + continuousGestureDetector = new ContinuousGestureDetector(); discreteGestureDetector = new DiscreteGestureDetector(continuousGestureDetector); filter.Init(); @@ -124,16 +122,16 @@ namespace ExplorVizGestureControl filter.UpdateFilter(body); CameraSpacePoint[] filteredJoints = filter.GetFilteredJoints(); Vector3D[] accumulatedJoints = jointAccumulator.accumulateJoints(filteredJoints); - gestureDatabase.refreshJoints(filteredJoints, accumulatedJoints, body.HandRightState, body.HandLeftState); - discreteGestureDetector.gestureRecognition(gestureDatabase); + GestureDatabase.refreshJoints(filteredJoints, accumulatedJoints, body.HandRightState, body.HandLeftState); + discreteGestureDetector.gestureRecognition(); if (drawBody) { - bodyStream.DrawBodies(gestureDatabase); + bodyStream.DrawBodies(); cleanBitmap = false; } if (discreteGestureDetector.detectContinousGestures) - continuousGestureDetector.DetectContinousGestures(gestureDatabase); + continuousGestureDetector.DetectContinousGestures(); } } if ((!AnyBodyTracked() && !cleanBitmap) || !drawBody) diff --git a/ExplorVizGestureControl/Streams and Drawing/BodyDrawing.cs b/ExplorVizGestureControl/Streams and Drawing/BodyDrawing.cs index 1c604e60ec34dd76fb2e20981170998641a1b1f8..c8721dc42a5d7f16fa42b69b59d6ab1a53884db5 100644 --- a/ExplorVizGestureControl/Streams and Drawing/BodyDrawing.cs +++ b/ExplorVizGestureControl/Streams and Drawing/BodyDrawing.cs @@ -35,7 +35,6 @@ namespace ExplorVizGestureControl.StreamsAndDrawing private int displayWidth = 480; private int displayHeight = 270; private List bodyColors; - private GestureDatabase database; #endregion #region Constructor @@ -105,10 +104,9 @@ namespace ExplorVizGestureControl.StreamsAndDrawing } - public void DrawBodies(GestureDatabase gestureDatabase) + public void DrawBodies() { - database = gestureDatabase; - CameraSpacePoint[] filteredJoints = database.filteredJoints; + CameraSpacePoint[] filteredJoints = GestureDatabase.filteredJoints; using (DrawingContext dc = this.drawingGroup.Open()) { @@ -162,28 +160,28 @@ namespace ExplorVizGestureControl.StreamsAndDrawing ColorSpacePoint phizColorSpacePoint = new ColorSpacePoint(); CameraSpacePoint phizCameraSpacePoint = new CameraSpacePoint(); List phizLines = new List(); - - phizCameraSpacePoint.X = (float)database.phiz.topRightCorner.X; - phizCameraSpacePoint.Y = (float)database.phiz.topRightCorner.Y; - phizCameraSpacePoint.Z = (float)database.phiz.z; + + phizCameraSpacePoint.X = (float)GestureDatabase.phiz.topRightCorner.X; + phizCameraSpacePoint.Y = (float)GestureDatabase.phiz.topRightCorner.Y; + phizCameraSpacePoint.Z = (float)GestureDatabase.phiz.z; phizColorSpacePoint = coordinateMapper.MapCameraPointToColorSpace(phizCameraSpacePoint); phizLines.Add(new Point(phizColorSpacePoint.X / 4, phizColorSpacePoint.Y / 4)); - - phizCameraSpacePoint.X = (float)database.phiz.botRightCorner.X; - phizCameraSpacePoint.Y = (float)database.phiz.botRightCorner.Y; - phizCameraSpacePoint.Z = (float)database.phiz.z; + + phizCameraSpacePoint.X = (float)GestureDatabase.phiz.botRightCorner.X; + phizCameraSpacePoint.Y = (float)GestureDatabase.phiz.botRightCorner.Y; + phizCameraSpacePoint.Z = (float)GestureDatabase.phiz.z; phizColorSpacePoint = coordinateMapper.MapCameraPointToColorSpace(phizCameraSpacePoint); phizLines.Add(new Point(phizColorSpacePoint.X / 4, phizColorSpacePoint.Y / 4)); - phizCameraSpacePoint.X = (float)database.phiz.topLeftCorner.X; - phizCameraSpacePoint.Y = (float)database.phiz.topLeftCorner.Y; - phizCameraSpacePoint.Z = (float)database.phiz.z; + phizCameraSpacePoint.X = (float)GestureDatabase.phiz.topLeftCorner.X; + phizCameraSpacePoint.Y = (float)GestureDatabase.phiz.topLeftCorner.Y; + phizCameraSpacePoint.Z = (float)GestureDatabase.phiz.z; phizColorSpacePoint = coordinateMapper.MapCameraPointToColorSpace(phizCameraSpacePoint); phizLines.Add(new Point(phizColorSpacePoint.X / 4, phizColorSpacePoint.Y / 4)); - phizCameraSpacePoint.X = (float)database.phiz.botLeftCorner.X; - phizCameraSpacePoint.Y = (float)database.phiz.botLeftCorner.Y; - phizCameraSpacePoint.Z = (float)database.phiz.z; + phizCameraSpacePoint.X = (float)GestureDatabase.phiz.botLeftCorner.X; + phizCameraSpacePoint.Y = (float)GestureDatabase.phiz.botLeftCorner.Y; + phizCameraSpacePoint.Z = (float)GestureDatabase.phiz.z; phizColorSpacePoint = coordinateMapper.MapCameraPointToColorSpace(phizCameraSpacePoint); phizLines.Add(new Point(phizColorSpacePoint.X / 4, phizColorSpacePoint.Y / 4)); diff --git a/ExplorVizGestureControl/bin/Debug/ExplorVizGestureControl.exe b/ExplorVizGestureControl/bin/Debug/ExplorVizGestureControl.exe index 557ba70c69989c50ddb49fdad28a08d12433ba21..8c2b027be1ab5d9e6a178fd15c1f51d4dd55e40b 100644 Binary files a/ExplorVizGestureControl/bin/Debug/ExplorVizGestureControl.exe and b/ExplorVizGestureControl/bin/Debug/ExplorVizGestureControl.exe differ diff --git a/ExplorVizGestureControl/bin/Debug/ExplorVizGestureControl.pdb b/ExplorVizGestureControl/bin/Debug/ExplorVizGestureControl.pdb index 6978131a82da7148790d3aef80d9fd1a5a4ff66f..13d76da3f26de6692e7e9f60f0ec4a56a5ddea10 100644 Binary files a/ExplorVizGestureControl/bin/Debug/ExplorVizGestureControl.pdb and b/ExplorVizGestureControl/bin/Debug/ExplorVizGestureControl.pdb differ diff --git a/ExplorVizGestureControl/obj/Debug/ExplorVizGestureControl.exe b/ExplorVizGestureControl/obj/Debug/ExplorVizGestureControl.exe index 557ba70c69989c50ddb49fdad28a08d12433ba21..8c2b027be1ab5d9e6a178fd15c1f51d4dd55e40b 100644 Binary files a/ExplorVizGestureControl/obj/Debug/ExplorVizGestureControl.exe and b/ExplorVizGestureControl/obj/Debug/ExplorVizGestureControl.exe differ