Commit 6df06c71 authored by Alexander Krause's avatar Alexander Krause

fixes for static fields

parent e0739219
...@@ -18,8 +18,7 @@ namespace ExplorVizGestureControl.Gestures ...@@ -18,8 +18,7 @@ namespace ExplorVizGestureControl.Gestures
public class ContinuousGestureDetector public class ContinuousGestureDetector
{ {
#region Variables #region Variables
private CoordinateMapper coordinateMapper = null; private CoordinateMapper coordinateMapper = null;
private GestureDatabase gestureDatabase = null;
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] [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); private static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
...@@ -68,14 +67,14 @@ namespace ExplorVizGestureControl.Gestures ...@@ -68,14 +67,14 @@ namespace ExplorVizGestureControl.Gestures
#endregion #endregion
public void DetectContinousGestures(GestureDatabase database) public void DetectContinousGestures()
{ {
if (delayTimer.busy) return; if (delayTimer.busy) return;
gestureDatabase = database;
handRight = gestureDatabase.handRight; handRight = GestureDatabase.handRight;
handLeft = gestureDatabase.handLeft; handLeft = GestureDatabase.handLeft;
phiz = gestureDatabase.phiz; phiz = GestureDatabase.phiz;
// Detect and handle continuous gestures // Detect and handle continuous gestures
...@@ -108,11 +107,11 @@ namespace ExplorVizGestureControl.Gestures ...@@ -108,11 +107,11 @@ namespace ExplorVizGestureControl.Gestures
{ {
if (gripActive) return; if (gripActive) return;
if (gestureDatabase.BothHandsParallel(2) && if (GestureDatabase.BothHandsParallel(2) &&
gestureDatabase.BothHandsAboveSpineBase() && GestureDatabase.BothHandsAboveSpineBase() &&
gestureDatabase.RightHandBelowRightShoulder() && GestureDatabase.RightHandBelowRightShoulder() &&
gestureDatabase.LeftHandBelowLeftShoulder() && GestureDatabase.LeftHandBelowLeftShoulder() &&
gestureDatabase.BothHandsOpen()) GestureDatabase.BothHandsOpen())
{ {
if (!rotationActive) if (!rotationActive)
{ {
...@@ -161,8 +160,8 @@ namespace ExplorVizGestureControl.Gestures ...@@ -161,8 +160,8 @@ namespace ExplorVizGestureControl.Gestures
{ {
if (gripActive) return; if (gripActive) return;
int scrollValue = 0; int scrollValue = 0;
double distance = gestureDatabase.spineBase.Z - gestureDatabase.oldSpineBase.Z; double distance = GestureDatabase.spineBase.Z - GestureDatabase.oldSpineBase.Z;
//if (distance > dynamicValues["scrollForwardFactor"] || //if (distance > dynamicValues["scrollForwardFactor"] ||
// distance < dynamicValues["scrollBackwardFactor"]) // distance < dynamicValues["scrollBackwardFactor"])
...@@ -182,7 +181,7 @@ namespace ExplorVizGestureControl.Gestures ...@@ -182,7 +181,7 @@ namespace ExplorVizGestureControl.Gestures
private void HandleGripAndSelection() private void HandleGripAndSelection()
{ {
if (gestureDatabase.DragObject()) if (GestureDatabase.DragObject())
{ {
if (!gripActive) if (!gripActive)
{ {
......
...@@ -40,9 +40,9 @@ namespace ExplorVizGestureControl.Gestures ...@@ -40,9 +40,9 @@ namespace ExplorVizGestureControl.Gestures
#endregion #endregion
#region Gesture recognition #region Gesture recognition
public void gestureRecognition(GestureDatabase gestureDatabase) public void gestureRecognition()
{ {
foreach (KeyValuePair<string, Func<bool>> entry in gestureDatabase.GestureDictionary) foreach (KeyValuePair<string, Func<bool>> entry in GestureDatabase.GestureDictionary)
{ {
if (entry.Value.Invoke() && !this.timerForNextGesture.busy) if (entry.Value.Invoke() && !this.timerForNextGesture.busy)
......
...@@ -30,8 +30,7 @@ namespace ExplorVizGestureControl ...@@ -30,8 +30,7 @@ namespace ExplorVizGestureControl
private Body[] bodies; private Body[] bodies;
private BodyFrameReader bodyReader; private BodyFrameReader bodyReader;
private ContinuousGestureDetector continuousGestureDetector; private ContinuousGestureDetector continuousGestureDetector;
private GestureDatabase gestureDatabase;
private DiscreteGestureDetector discreteGestureDetector; private DiscreteGestureDetector discreteGestureDetector;
private KinectJointFilter filter = new KinectJointFilter(); private KinectJointFilter filter = new KinectJointFilter();
...@@ -69,8 +68,7 @@ namespace ExplorVizGestureControl ...@@ -69,8 +68,7 @@ namespace ExplorVizGestureControl
FrameworkElement xamlElement = new FrameworkElement(); FrameworkElement xamlElement = new FrameworkElement();
xamlElement.Style = (Style)this.FindResource("Stream"); xamlElement.Style = (Style)this.FindResource("Stream");
continuousGestureDetector = new ContinuousGestureDetector(); continuousGestureDetector = new ContinuousGestureDetector();
gestureDatabase = new GestureDatabase();
discreteGestureDetector = new DiscreteGestureDetector(continuousGestureDetector); discreteGestureDetector = new DiscreteGestureDetector(continuousGestureDetector);
filter.Init(); filter.Init();
...@@ -124,16 +122,16 @@ namespace ExplorVizGestureControl ...@@ -124,16 +122,16 @@ namespace ExplorVizGestureControl
filter.UpdateFilter(body); filter.UpdateFilter(body);
CameraSpacePoint[] filteredJoints = filter.GetFilteredJoints(); CameraSpacePoint[] filteredJoints = filter.GetFilteredJoints();
Vector3D[] accumulatedJoints = jointAccumulator.accumulateJoints(filteredJoints); Vector3D[] accumulatedJoints = jointAccumulator.accumulateJoints(filteredJoints);
gestureDatabase.refreshJoints(filteredJoints, accumulatedJoints, body.HandRightState, body.HandLeftState); GestureDatabase.refreshJoints(filteredJoints, accumulatedJoints, body.HandRightState, body.HandLeftState);
discreteGestureDetector.gestureRecognition(gestureDatabase); discreteGestureDetector.gestureRecognition();
if (drawBody) if (drawBody)
{ {
bodyStream.DrawBodies(gestureDatabase); bodyStream.DrawBodies();
cleanBitmap = false; cleanBitmap = false;
} }
if (discreteGestureDetector.detectContinousGestures) if (discreteGestureDetector.detectContinousGestures)
continuousGestureDetector.DetectContinousGestures(gestureDatabase); continuousGestureDetector.DetectContinousGestures();
} }
} }
if ((!AnyBodyTracked() && !cleanBitmap) || !drawBody) if ((!AnyBodyTracked() && !cleanBitmap) || !drawBody)
......
...@@ -35,7 +35,6 @@ namespace ExplorVizGestureControl.StreamsAndDrawing ...@@ -35,7 +35,6 @@ namespace ExplorVizGestureControl.StreamsAndDrawing
private int displayWidth = 480; private int displayWidth = 480;
private int displayHeight = 270; private int displayHeight = 270;
private List<Pen> bodyColors; private List<Pen> bodyColors;
private GestureDatabase database;
#endregion #endregion
#region Constructor #region Constructor
...@@ -105,10 +104,9 @@ namespace ExplorVizGestureControl.StreamsAndDrawing ...@@ -105,10 +104,9 @@ namespace ExplorVizGestureControl.StreamsAndDrawing
} }
public void DrawBodies(GestureDatabase gestureDatabase) public void DrawBodies()
{ {
database = gestureDatabase; CameraSpacePoint[] filteredJoints = GestureDatabase.filteredJoints;
CameraSpacePoint[] filteredJoints = database.filteredJoints;
using (DrawingContext dc = this.drawingGroup.Open()) using (DrawingContext dc = this.drawingGroup.Open())
{ {
...@@ -162,28 +160,28 @@ namespace ExplorVizGestureControl.StreamsAndDrawing ...@@ -162,28 +160,28 @@ namespace ExplorVizGestureControl.StreamsAndDrawing
ColorSpacePoint phizColorSpacePoint = new ColorSpacePoint(); ColorSpacePoint phizColorSpacePoint = new ColorSpacePoint();
CameraSpacePoint phizCameraSpacePoint = new CameraSpacePoint(); CameraSpacePoint phizCameraSpacePoint = new CameraSpacePoint();
List<Point> phizLines = new List<Point>(); List<Point> phizLines = new List<Point>();
phizCameraSpacePoint.X = (float)database.phiz.topRightCorner.X; phizCameraSpacePoint.X = (float)GestureDatabase.phiz.topRightCorner.X;
phizCameraSpacePoint.Y = (float)database.phiz.topRightCorner.Y; phizCameraSpacePoint.Y = (float)GestureDatabase.phiz.topRightCorner.Y;
phizCameraSpacePoint.Z = (float)database.phiz.z; phizCameraSpacePoint.Z = (float)GestureDatabase.phiz.z;
phizColorSpacePoint = coordinateMapper.MapCameraPointToColorSpace(phizCameraSpacePoint); phizColorSpacePoint = coordinateMapper.MapCameraPointToColorSpace(phizCameraSpacePoint);
phizLines.Add(new Point(phizColorSpacePoint.X / 4, phizColorSpacePoint.Y / 4)); phizLines.Add(new Point(phizColorSpacePoint.X / 4, phizColorSpacePoint.Y / 4));
phizCameraSpacePoint.X = (float)database.phiz.botRightCorner.X; phizCameraSpacePoint.X = (float)GestureDatabase.phiz.botRightCorner.X;
phizCameraSpacePoint.Y = (float)database.phiz.botRightCorner.Y; phizCameraSpacePoint.Y = (float)GestureDatabase.phiz.botRightCorner.Y;
phizCameraSpacePoint.Z = (float)database.phiz.z; phizCameraSpacePoint.Z = (float)GestureDatabase.phiz.z;
phizColorSpacePoint = coordinateMapper.MapCameraPointToColorSpace(phizCameraSpacePoint); phizColorSpacePoint = coordinateMapper.MapCameraPointToColorSpace(phizCameraSpacePoint);
phizLines.Add(new Point(phizColorSpacePoint.X / 4, phizColorSpacePoint.Y / 4)); phizLines.Add(new Point(phizColorSpacePoint.X / 4, phizColorSpacePoint.Y / 4));
phizCameraSpacePoint.X = (float)database.phiz.topLeftCorner.X; phizCameraSpacePoint.X = (float)GestureDatabase.phiz.topLeftCorner.X;
phizCameraSpacePoint.Y = (float)database.phiz.topLeftCorner.Y; phizCameraSpacePoint.Y = (float)GestureDatabase.phiz.topLeftCorner.Y;
phizCameraSpacePoint.Z = (float)database.phiz.z; phizCameraSpacePoint.Z = (float)GestureDatabase.phiz.z;
phizColorSpacePoint = coordinateMapper.MapCameraPointToColorSpace(phizCameraSpacePoint); phizColorSpacePoint = coordinateMapper.MapCameraPointToColorSpace(phizCameraSpacePoint);
phizLines.Add(new Point(phizColorSpacePoint.X / 4, phizColorSpacePoint.Y / 4)); phizLines.Add(new Point(phizColorSpacePoint.X / 4, phizColorSpacePoint.Y / 4));
phizCameraSpacePoint.X = (float)database.phiz.botLeftCorner.X; phizCameraSpacePoint.X = (float)GestureDatabase.phiz.botLeftCorner.X;
phizCameraSpacePoint.Y = (float)database.phiz.botLeftCorner.Y; phizCameraSpacePoint.Y = (float)GestureDatabase.phiz.botLeftCorner.Y;
phizCameraSpacePoint.Z = (float)database.phiz.z; phizCameraSpacePoint.Z = (float)GestureDatabase.phiz.z;
phizColorSpacePoint = coordinateMapper.MapCameraPointToColorSpace(phizCameraSpacePoint); phizColorSpacePoint = coordinateMapper.MapCameraPointToColorSpace(phizCameraSpacePoint);
phizLines.Add(new Point(phizColorSpacePoint.X / 4, phizColorSpacePoint.Y / 4)); phizLines.Add(new Point(phizColorSpacePoint.X / 4, phizColorSpacePoint.Y / 4));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment