Browse Source

added handStatus

Alexander Hendrich 11 years ago
parent
commit
51707908e2
2 changed files with 32 additions and 7 deletions
  1. 3 2
      bbiwarg/DataSource/IVideoDataSource.cs
  2. 29 5
      bbiwarg/DataSource/IisuDataSource.cs

+ 3 - 2
bbiwarg/DataSource/IVideoDataSource.cs

@@ -4,7 +4,7 @@ using MathNet.Numerics.LinearAlgebra.Single;
 
 namespace bbiwarg.DataSource
 {
-    public enum FingerStatus
+    public enum DetectionStatus
     {
         Inactive,
         Detected,
@@ -73,7 +73,8 @@ namespace bbiwarg.DataSource
         Vector getTipPosition3D(uint handIndex);
         Vector getForearmPosition3D(uint handIndex);
         Vector getPalmNormal3D(uint handIndex);
-        FingerStatus[] getFingerStatus(uint handIndex);
+        DetectionStatus[] getFingerStatus(uint handIndex);
+        DetectionStatus getHandStatus(uint handIndex);
         Vector[] getFingerTipPositions3D(uint handIndex);
         Vector[] getFingerTipPositions2D(uint handIndex);
         HandSide getHandSide(uint handIndex);

+ 29 - 5
bbiwarg/DataSource/IisuDataSource.cs

@@ -24,6 +24,7 @@ namespace bbiwarg.DataSource
         private IDataHandle<Iisu.Data.Vector3>[] forearmPositions3D = new IDataHandle<Iisu.Data.Vector3>[2];
         private IDataHandle<Iisu.Data.Vector3>[] palmNormals3D = new IDataHandle<Iisu.Data.Vector3>[2];
         private IDataHandle<int[]>[] fingerStatus = new IDataHandle<int[]>[2];
+        private IDataHandle<int>[] handStatus = new IDataHandle<int>[2];
         private IDataHandle<Iisu.Data.Vector3[]>[] fingerTipPositions3D = new IDataHandle<Iisu.Data.Vector3[]>[2];
         private IDataHandle<Iisu.Data.Vector2[]>[] fingerTipPositions2D = new IDataHandle<Iisu.Data.Vector2[]>[2];
         private IDataHandle<int>[] handSides = new IDataHandle<int>[2];
@@ -96,6 +97,9 @@ namespace bbiwarg.DataSource
             fingerStatus[0] = device.RegisterDataHandle<int[]>("CI.HAND1.FingerStatus");
             fingerStatus[1] = device.RegisterDataHandle<int[]>("CI.HAND2.FingerStatus");
 
+            handStatus[0] = device.RegisterDataHandle<int>("CI.HAND1.Status");
+            handStatus[1] = device.RegisterDataHandle<int>("CI.HAND2.Status");
+
             fingerTipPositions3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3[]>("CI.HAND1.FingerTipPositions3D");
             fingerTipPositions3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3[]>("CI.HAND2.FingerTipPositions3D");
             
@@ -256,29 +260,49 @@ namespace bbiwarg.DataSource
             return new DenseVector(palmNormals3D[handIndex - 1].Value.ToArray());
         }
 
-        public FingerStatus[] getFingerStatus(uint handIndex)
+        public DetectionStatus[] getFingerStatus(uint handIndex)
         {
             checkHandIndex(handIndex);
             int[] status = fingerStatus[handIndex - 1].Value;
-            FingerStatus[] result = new FingerStatus[status.Length];
+            DetectionStatus[] result = new DetectionStatus[status.Length];
             for (int i = 0; i < status.Length; ++i)
             {
                 switch (status[i])
                 {
                     case 0:
-                        result[i] = FingerStatus.Inactive;
+                        result[i] = DetectionStatus.Inactive;
                         break;
                     case 1:
-                        result[i] = FingerStatus.Detected;
+                        result[i] = DetectionStatus.Detected;
                         break;
                     case 2:
-                        result[i] = FingerStatus.Tracked;
+                        result[i] = DetectionStatus.Tracked;
                         break;
                 }
             }
             return result;
         }
 
+        public DetectionStatus getHandStatus(uint handIndex)
+        {
+            checkHandIndex(handIndex);
+            int status = handStatus[handIndex - 1].Value;
+            DetectionStatus result = new DetectionStatus();
+            switch (status)
+            {
+                case 0:
+                    result = DetectionStatus.Inactive;
+                    break;
+                case 1:
+                    result = DetectionStatus.Detected;
+                    break;
+                case 2:
+                    result = DetectionStatus.Tracked;
+                    break;
+            }
+            return result;
+        }
+
         public Vector[] getFingerTipPositions3D(uint handIndex)
         {
             checkHandIndex(handIndex);