Commit baa5e1e4 authored by Alexander Krause's avatar Alexander Krause

process centered body only

parent 07a53b95
......@@ -79,8 +79,8 @@ namespace ExplorVizGestureControl.Gestures
Zoom();
Rotation();
if (IntersectWithPhIZ() || flags[1] == 1) GripAndSelection();
if ((IntersectWithPhIZ()) || flags[1] == 1) GripAndSelection();
}
private bool IntersectWithPhIZ()
......@@ -177,7 +177,7 @@ namespace ExplorVizGestureControl.Gestures
private void Zoom()
{
if (flags[0] == 1 || flags[1] == 1 || timers[0].busy) return;
if (flags[0] == 1 || timers[0].busy) return;
int zoomingActive = 2;
int zoomStatus = 5;
......@@ -248,7 +248,7 @@ namespace ExplorVizGestureControl.Gestures
int gripActive = 1;
int selectionStatus = 4;
int selectionAnchorLength = 0;
int selectionAnchorLength = 0;
if (!GestureDatabase.RightHandClosed() && flags[selectionStatus] == 1)
{
......
......@@ -86,6 +86,10 @@ namespace ExplorVizGestureControl.Gestures
{
return this.detectContinuousGestures;
}
set
{
this.detectContinuousGestures = value;
}
}
}
......
......@@ -34,7 +34,6 @@ namespace ExplorVizGestureControl
#region Variables
private int WM_APPCOMMAND = 0x0319;
private HotKey resetHotKey;
private KinectSensor kinect;
......@@ -100,7 +99,7 @@ namespace ExplorVizGestureControl
notifyIcon.Visible = true;
notifyIcon.ShowBalloonTip(1);
notifyIcon.DoubleClick +=
delegate(object sender, EventArgs args)
delegate (object sender, EventArgs args)
{
Show();
WindowState = WindowState.Normal;
......@@ -133,35 +132,33 @@ namespace ExplorVizGestureControl
{
frame.GetAndRefreshBodyData(bodies);
// Loop all bodies
int length = bodies.Length;
for (int i = 0; i < length; i++)
bodyIndex = GetCenteredBodyIndex();
if (bodies[bodyIndex].IsTracked && NoClippedEdges(bodies[bodyIndex]))
{
Body body = bodies[i];
filter.UpdateFilter(bodies[bodyIndex]);
CameraSpacePoint[] filteredJoints = filter.GetFilteredJoints();
Vector3D[] accumulatedJoints = jointAccumulator.AccumulateJoints(filteredJoints);
GestureDatabase.RefreshJoints(filteredJoints, accumulatedJoints, bodies[bodyIndex].HandRightState, bodies[bodyIndex].HandLeftState);
//discreteGestureDetector.GestureRecognition();
// Only process the first tracked body
if (body.IsTracked && IsFirstTrackedBody(body, i) && NoClippedEdges(body))
if (drawBody)
{
filter.UpdateFilter(body);
CameraSpacePoint[] filteredJoints = filter.GetFilteredJoints();
Vector3D[] accumulatedJoints = jointAccumulator.AccumulateJoints(filteredJoints);
GestureDatabase.RefreshJoints(filteredJoints, accumulatedJoints, body.HandRightState, body.HandLeftState);
//discreteGestureDetector.GestureRecognition();
if (drawBody)
{
bodyStream.DrawBodies();
cleanBitmap = false;
}
if (discreteGestureDetector.DetectContinuousGestures)
continuousGestureDetector.DetectContinousGestures();
bodyStream.DrawBodies();
cleanBitmap = false;
}
if (discreteGestureDetector.DetectContinuousGestures)
continuousGestureDetector.DetectContinousGestures();
}
if ((!AnyBodyTracked() && !cleanBitmap) || !drawBody)
if ((!BodyTracked() && !cleanBitmap) || !drawBody)
{
bodyStream.ResetDrawing();
cleanBitmap = true;
}
}
}
......@@ -170,27 +167,52 @@ namespace ExplorVizGestureControl
#region Helper
private int GetCenteredBodyIndex()
{
int length = bodies.Length;
int currentIndex = length + 1;
float currentX = 0;
for (int i = 0; i < length; i++)
{
Body body = bodies[i];
if (!body.IsTracked) continue;
if (currentIndex > length)
{
currentIndex = i;
currentX = body.Joints[JointType.SpineMid].Position.X;
continue;
}
float tempX = body.Joints[JointType.SpineMid].Position.X;
if (Math.Abs(tempX) < Math.Abs(currentX))
{
currentIndex = i;
currentX = tempX;
continue;
}
}
if (currentIndex > length) return 0;
return currentIndex;
}
private bool NoClippedEdges(Body body)
{
FrameEdges clippedEdges = body.ClippedEdges;
return clippedEdges.HasFlag(FrameEdges.Top) ||
clippedEdges.HasFlag(FrameEdges.Left) ||
clippedEdges.HasFlag(FrameEdges.Right) ? false : true;
}
private bool IsFirstTrackedBody(Body body, int index)
{
if (bodyTrackingID == 0)
{
bodyTrackingID = body.TrackingId;
bodyIndex = index;
}
return bodyTrackingID == body.TrackingId ? true : false;
}
private bool AnyBodyTracked()
private bool BodyTracked()
{
if (bodies[bodyIndex].IsTracked)
{
......@@ -255,7 +277,7 @@ namespace ExplorVizGestureControl
{
if (e.Key == Key.Return)
{
TextBox textBox = sender as TextBox;
TextBox textBox = sender as TextBox;
continuousGestureDetector.UpdateDynamicValues(textBox.Name, Convert.ToDouble(textBox.Text));
}
}
......@@ -266,7 +288,10 @@ namespace ExplorVizGestureControl
{
keybd_event(0x26, 0, 0x0001, 0);
keybd_event(0x26, 0, 0x0002, 0);
}
ContinuousGestureDetector.delayTimer.StartTimer();
discreteGestureDetector.DetectContinuousGestures = true;
}
}
#endregion
......
......@@ -4,12 +4,12 @@
winexe
C#
.cs
C:\Users\Alexander\Desktop\Git\gesture-control\ExplorVizGestureControl\obj\Debug\
C:\Users\Virtual-Reality\Documents\gesture-control\ExplorVizGestureControl\obj\Debug\
ExplorVizGestureControl
none
false
DEBUG;TRACE
C:\Users\Alexander\Desktop\Git\gesture-control\ExplorVizGestureControl\App.xaml
C:\Users\Virtual-Reality\Documents\gesture-control\ExplorVizGestureControl\App.xaml
11151548125
161086153555
......
......@@ -4,15 +4,15 @@
winexe
C#
.cs
C:\Users\Alexander\Desktop\Git\gesture-control\ExplorVizGestureControl\obj\Debug\
C:\Users\Virtual-Reality\Documents\gesture-control\ExplorVizGestureControl\obj\Debug\
ExplorVizGestureControl
none
false
DEBUG;TRACE
C:\Users\Alexander\Desktop\Git\gesture-control\ExplorVizGestureControl\App.xaml
C:\Users\Virtual-Reality\Documents\gesture-control\ExplorVizGestureControl\App.xaml
11151548125
20-467838495
20-288322765
151583282685
MainWindow.xaml;
......
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