Browse Source

-improved touchDetection (only counts pixels with higher depth than tip)
-improved fingerDetection alignment (lower slice size = tip)

Alexander Hendrich 10 years ago
parent
commit
07fad4ced1

+ 4 - 0
bbiwarg/Detectors/Fingers/Finger.cs

@@ -18,6 +18,10 @@ namespace bbiwarg.Detectors.Fingers
 
         public Finger(FingerSliceTrail sliceTrail)
         {
+            //check direction
+            if (sliceTrail.Start.Length > sliceTrail.End.Length)
+                sliceTrail.Slices.Reverse();
+
             SliceTrail = sliceTrail;
         }
 

+ 2 - 2
bbiwarg/Detectors/Fingers/FingerDetector.cs

@@ -180,7 +180,7 @@ namespace bbiwarg.Detectors.Fingers
             int maxX = depthImage.Width - 1;
             int maxY = depthImage.Height - 1;
 
-            int maxFingerSize = 30;
+            int maxFingerSize = 35;
 
             int maxStepsX;
             if (direction.X > 0)
@@ -221,7 +221,7 @@ namespace bbiwarg.Detectors.Fingers
             int maxY = depthImage.Height - 1;
 
             int minFingerSize = 5;
-            int maxFingerSize = 30;
+            int maxFingerSize = 35;
 
             Vector2D direction = (end - start).normalize();
             Vector2D beforeStart = start - direction;

+ 2 - 2
bbiwarg/Detectors/Touch/TouchDetector.cs

@@ -27,7 +27,7 @@ namespace bbiwarg.Detectors.Touch
             this.outputImage = outputImage;
             this.fingers = fingers;
             this.TouchEvents = new List<TouchEvent>();
-            float floodValueThreshold = 0.5f;
+            float floodValueThreshold = 0.33f;
 
             foreach (Finger finger in fingers)
             {
@@ -71,7 +71,7 @@ namespace bbiwarg.Detectors.Touch
                     Int16 depth = depthImage.getDepthAt(x, y);
                     Color color = outputImage.getColotAt(x, y);
                     Color subtractColor;
-                    if (Math.Abs(depthAtTouch - depth) < maxDepthDifference)
+                    if (depthAtTouch < depth && Math.Abs(depthAtTouch - depth) < maxDepthDifference)
                     {
                         matchedPixels++;
                         subtractColor = Constants.TouchEventAreaMatchedSubtractColor;

+ 1 - 1
bbiwarg/MainBBWIWARG.cs

@@ -12,7 +12,7 @@ namespace bbiwarg
     {
         static void Main(string[] args)
         {
-            IInputProvider inputProvider = new IisuInputProvider(""); //..\\..\\videos\\touch\\4.skv");
+            IInputProvider inputProvider = new IisuInputProvider("..\\..\\videos\\touch\\4.skv");
             VideoHandle videoHandle = new VideoHandle(inputProvider);
             videoHandle.start();
 

+ 7 - 0
bbiwarg/Utility/Vector2D.cs

@@ -74,6 +74,13 @@ namespace bbiwarg.Utility
             return new Vector2D(X / length, Y / length);
         }
 
+        public Vector2D normalizeComponentOne() {
+            if (Math.Abs(X) > Math.Abs(Y))
+                return new Vector2D(1, Y / X);
+            else
+                return new Vector2D(X / Y, 1);
+        } 
+
         public bool isWithin(float minX, float minY, float maxX, float maxY)
         {
             return (X >= minX && Y >= minY && X <= maxX && Y <= maxY);