Ver Fonte

improved touch stability
fixed IndexOutOfRangeException

Alexander Hendrich há 10 anos atrás
pai
commit
828f8bee0b

+ 2 - 1
bbiwarg/InputHandler.cs

@@ -233,7 +233,8 @@ namespace bbiwarg
             OutputImages[0].drawImage((depthImage.MaxDepth - depthImage.MinDepth) - depthImage.Image, Parameters.DepthImageColor);
             foreach (Finger f in fingerTracker.Fingers)
             {
-                OutputImages[0].fillCircle(f.TipPoint.IntX, f.TipPoint.IntY, 5, Parameters.FingerTipColor);
+                Color color = (f.TouchEvent != null) ? Parameters.TouchEventDetectedColor : Parameters.FingerTipColor;
+                OutputImages[0].fillCircle(f.TipPoint.IntX, f.TipPoint.IntY, 5, color);
             }
 
             foreach (TrackedFinger tf in fingerTracker.TrackedObjects)

+ 5 - 5
bbiwarg/Parameters.cs

@@ -125,18 +125,18 @@ namespace bbiwarg
         public static int PalmGridNumColumns = 4;
 
         // touch detection
-        public static readonly float TouchMinTouchValue = 0.3f;
+        public static readonly float TouchMinTouchValue = 0.4f;
         public static readonly int TouchAreaSize = 30;
-        public static readonly int TouchFloodfillDownDiff = 1;
-        public static readonly int TouchFloodfillUpDiff = 3;
+        public static readonly int TouchFloodfillDownDiff = 0;
+        public static readonly int TouchFloodfillUpDiff = 2;
         public static readonly int TouchTipInsideFactor = 2;
-        public static readonly int TouchTipOutsideFactor = 7;
+        public static readonly int TouchTipOutsideFactor = 10;
 
         // touch tracking
         public static readonly int TouchTrackerNumFramesDetectedUntilTracked = 1;
         public static readonly int TouchTrackerNumFramesLostUntilDeleted = 5;
         public static readonly float TouchTrackerMaxAbsolutePositionMove = 0.25f * ImageDiagonalLength;
-        public static readonly float TouchTrackerMaxRelativePositionMove = 0.5f;
+        public static readonly float TouchTrackerMaxRelativePositionMove = 1f;
         public static readonly float TouchmXX = 0.003f;
         public static readonly float TouchmXY = 0.0f;
         public static readonly float TouchmYY = 0.00165f;

+ 9 - 8
bbiwarg/Recognition/HandRecognition/Hand.cs

@@ -113,14 +113,15 @@ namespace bbiwarg.Recognition.HandRecognition
 
         private void findConvexityDefects()
         {
-            MemStorage ms = new MemStorage();
-            Contour<Point> contour = Mask.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_EXTERNAL);
-            List<MCvConvexityDefect> mcvConvexityDefects = new List<MCvConvexityDefect>(contour.GetConvexityDefacts(ms, Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE));
-
-            ConvexityDefects = new List<ConvexityDefect>();
-            foreach (MCvConvexityDefect defect in mcvConvexityDefects)
-                ConvexityDefects.Add(new ConvexityDefect(defect));
-            ms.Clear();
+            using (MemStorage ms = new MemStorage())
+            {
+                Contour<Point> contour = Mask.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_EXTERNAL);
+                List<MCvConvexityDefect> mcvConvexityDefects = new List<MCvConvexityDefect>(contour.GetConvexityDefacts(ms, Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE));
+
+                ConvexityDefects = new List<ConvexityDefect>();
+                foreach (MCvConvexityDefect defect in mcvConvexityDefects)
+                    ConvexityDefects.Add(new ConvexityDefect(defect));
+            }
         }
 
         private void filterThumbDefect()

+ 1 - 1
bbiwarg/Recognition/PalmRecognition/PalmDetector.cs

@@ -60,8 +60,8 @@ namespace bbiwarg.Recognition.PalmRecognition
                     bool handBelowFound = false;
                     while (!handBelowFound && below.getDistanceTo(fingersUpper) < 2 * Parameters.FingerMaxWidth && below.isInBound())
                     {
-                        below += directionUpperLower;
                         handBelowFound = palmHand.isInside(below);
+                        below += directionUpperLower;
                     }
                     handBelow = handBelowFound;
                 }

+ 0 - 1
bbiwarg/Recognition/TouchRecognition/TouchDetector.cs

@@ -45,7 +45,6 @@ namespace bbiwarg.Recognition.TouchRecognition
                 {
                     if (palm.isInside(tipPointOutside))
                     {
-
                         Image<Gray, byte> touchMask = getTouchMask(tipPointInside);
 
                         int touchPixels = touchMask.CountNonzero()[0];