Browse Source

Merge branch 'master' of https://git.tk.informatik.tu-darmstadt.de/etri-smartspaces

Conflicts:
	bbiwarg/Constants.cs
Alexander Hendrich 10 years ago
parent
commit
2efe6c600e

+ 2 - 0
bbiwarg/Constants.cs

@@ -65,6 +65,8 @@ namespace bbiwarg
         public static readonly float PalmThumbDefectmYY = 50.0f;
         public static readonly float PalmThumbDefectProcessNoise = 5.0e+1f;
         public static readonly int PalmNumFramesNoHandReset = 5;
+        public static readonly float PalmMinAreaQuotient = 0.6f;
+        public static readonly float PalmMaxAreaQuotient = 1.4f;
 
         //palm Grid
         public static readonly int PalmGridRows = 3;

+ 10 - 4
bbiwarg/Recognition/PalmRecognition/PalmDetector.cs

@@ -25,11 +25,10 @@ namespace bbiwarg.Recognition.PalmRecognition
         private List<MCvConvexityDefect> convexityDefects;
         private Vector2D thumbDefectStart;
         private Vector2D thumbDefectEnd;
-        public Vector2D thumbDefectDepth;
-        
+        private Vector2D thumbDefectDepth;
         private Kalman2DPositionFilter thumbDefectDepthFilter, thumbDefectStartFilter, thumbDefectEndFilter;
-
         private int numFramesNoHandFound;
+        private float lastPalmQuadArea;
 
         public Quadrangle PalmQuad { get; private set; }
 
@@ -103,6 +102,7 @@ namespace bbiwarg.Recognition.PalmRecognition
             palmContour = null;
             PalmQuad = null;
             numFramesNoHandFound = 0;
+            lastPalmQuadArea = 0.0f;
         }
 
         private void findLongestPalmContour()
@@ -244,7 +244,13 @@ namespace bbiwarg.Recognition.PalmRecognition
                 bottomRight = bottomLeft + handWidth;
                 topRight = bottomRight + 1.2f * handLength - 0.3f * handWidth;
 
-                PalmQuad = new Quadrangle(bottomLeft, topLeft, topRight, bottomRight);
+                Quadrangle quad = new Quadrangle(bottomLeft, topLeft, topRight, bottomRight);
+                if (lastPalmQuadArea == 0.0f ||
+                    (quad.Area / lastPalmQuadArea >= Constants.PalmMinAreaQuotient && quad.Area / lastPalmQuadArea <= Constants.PalmMaxAreaQuotient))
+                {
+                    PalmQuad = quad;
+                    lastPalmQuadArea = PalmQuad.Area;
+                }
             }
         }
 

+ 10 - 0
bbiwarg/Utility/Quadrangle.cs

@@ -6,6 +6,8 @@ using System.Threading.Tasks;
 
 using System.Drawing;
 
+using Emgu.CV;
+
 namespace bbiwarg.Utility
 {
     class Quadrangle
@@ -15,6 +17,7 @@ namespace bbiwarg.Utility
         public Vector2D TopLeft { get; private set; }
         public Vector2D TopRight { get; private set; }
         public Vector2D BottomRight { get; private set; }
+        public float Area {get; private set;}
 
         public Quadrangle(Vector2D bottomLeft, Vector2D topLeft, Vector2D topRight, Vector2D bottomRight)
         {
@@ -22,6 +25,13 @@ namespace bbiwarg.Utility
             TopLeft = topLeft;
             TopRight = topRight;
             BottomRight = bottomRight;
+
+            Contour<PointF> points = new Contour<PointF>(new MemStorage());
+            points.Push(BottomLeft);
+            points.Push(TopLeft);
+            points.Push(TopRight);
+            points.Push(BottomRight);
+            Area = (float) points.Area;
         }