|
@@ -15,6 +15,16 @@
|
|
|
|
|
|
public partial class MainWindow : INotifyPropertyChanged
|
|
|
{
|
|
|
+
|
|
|
+ private bool open1 = false;
|
|
|
+ private bool open1a = false;
|
|
|
+ private bool open2 = false;
|
|
|
+ private bool open2a = false;
|
|
|
+ private bool open3 = false;
|
|
|
+ private bool open3a = false;
|
|
|
+ private bool open4 = false;
|
|
|
+ private bool open4a = false;
|
|
|
+ private int Count = 1;
|
|
|
|
|
|
private KinectSensor _kinectSensor = null;
|
|
|
|
|
@@ -199,8 +209,10 @@
|
|
|
Joint jointHandLeft = joints[JointType.HandLeft];
|
|
|
|
|
|
Joint jointShoulderLeft = joints[JointType.ShoulderLeft];
|
|
|
-
|
|
|
+
|
|
|
Joint jointSpineMid = joints[JointType.SpineBase];
|
|
|
+
|
|
|
+ Joint jointHead = joints[JointType.Head];
|
|
|
|
|
|
|
|
|
|
|
@@ -209,6 +221,15 @@
|
|
|
CameraSpacePoint positionHandLeft = jointHandLeft.Position;
|
|
|
|
|
|
CameraSpacePoint positionSpineMid = jointSpineMid.Position;
|
|
|
+
|
|
|
+ CameraSpacePoint positionHead = jointHead.Position;
|
|
|
+
|
|
|
+ CameraSpacePoint positionShoulderLeft = jointShoulderLeft.Position;
|
|
|
+
|
|
|
+ CameraSpacePoint positionShoulderRight = jointShoulderRight.Position;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
float xHandRight = positionHandRight.X;
|
|
@@ -227,8 +248,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
- Console.WriteLine(body.HandRightState);
|
|
|
- Console.WriteLine(body.HandLeftState);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
if (body.HandRightState == HandState.Closed && body.HandLeftState == HandState.Closed && yHandRight > ySpineMid && yHandLeft > xSpineMid)
|
|
|
{
|
|
@@ -261,7 +282,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
if (body.HandRightState == HandState.Lasso && body.HandLeftState == HandState.Lasso && yHandRight > ySpineMid && yHandLeft > xSpineMid)
|
|
|
{
|
|
|
|
|
@@ -288,6 +309,82 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ if (jointHead.TrackingState == TrackingState.Tracked
|
|
|
+ && jointHandRight.TrackingState == TrackingState.Tracked
|
|
|
+ && jointShoulderLeft.TrackingState == TrackingState.Tracked
|
|
|
+ && jointShoulderRight.TrackingState == TrackingState.Tracked)
|
|
|
+ {
|
|
|
+ if (positionHandRight.Y > positionHead.Y)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (positionHandRight.X < positionHead.X && positionHandRight.X > positionShoulderLeft.X)
|
|
|
+ {
|
|
|
+
|
|
|
+ open2 = true;
|
|
|
+ open2a = true;
|
|
|
+ }
|
|
|
+ if (positionHandRight.X > positionShoulderRight.X)
|
|
|
+ {
|
|
|
+
|
|
|
+ open1 = true;
|
|
|
+ open1a = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (open1 == true && open2 == true)
|
|
|
+ {
|
|
|
+ if (positionHandRight.Y < positionHead.Y)
|
|
|
+ {
|
|
|
+ Console.WriteLine("手势合格,麦克风打开.键盘输入 下键");
|
|
|
+ open1 = false;
|
|
|
+ open2 = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (jointHead.TrackingState == TrackingState.Tracked
|
|
|
+ && jointHandLeft.TrackingState == TrackingState.Tracked
|
|
|
+ && jointShoulderLeft.TrackingState == TrackingState.Tracked
|
|
|
+ && jointShoulderRight.TrackingState == TrackingState.Tracked)
|
|
|
+ {
|
|
|
+ if (positionHandLeft.Y > positionHead.Y)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (positionHead.X < positionHandLeft.X && positionHandLeft.X < positionShoulderRight.X)
|
|
|
+ {
|
|
|
+
|
|
|
+ open3 = true;
|
|
|
+ open3a = true;
|
|
|
+
|
|
|
+ }
|
|
|
+ if (positionHandLeft.X < positionShoulderLeft.X)
|
|
|
+ {
|
|
|
+
|
|
|
+ open4 = true;
|
|
|
+ open4a = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (open3 == true && open4 == true)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (positionHandLeft.Y < positionHead.Y)
|
|
|
+ {
|
|
|
+ Console.WriteLine("手势合格,麦克风关闭. 键盘输入 上键");
|
|
|
+
|
|
|
+ open3 = false;
|
|
|
+ open4 = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -295,6 +392,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+ if (open4 == true && open1 == true)
|
|
|
+ {
|
|
|
+ if (positionHandLeft.Y < positionHead.Y && positionHandRight.Y < positionHead.Y)
|
|
|
+ {
|
|
|
+ if (Count % 2 == 0)
|
|
|
+ {
|
|
|
+ Console.WriteLine("未知命令 执行 ");
|
|
|
+ open4 = false;
|
|
|
+ open1 = false;
|
|
|
+ Count++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Console.WriteLine("未知命令 退出");
|
|
|
+ open4 = false;
|
|
|
+ open1 = false;
|
|
|
+ Count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|