Browse Source

Started palm detection.

Daniel Kauth 10 years ago
parent
commit
e3cf3d42f1
4 changed files with 69 additions and 0 deletions
  1. 5 0
      bbiwarg/Images/EdgeImage.cs
  2. 56 0
      bbiwarg/Images/PalmImage.cs
  3. 7 0
      bbiwarg/VideoHandle.cs
  4. 1 0
      bbiwarg/bbiwarg.csproj

+ 5 - 0
bbiwarg/Images/EdgeImage.cs

@@ -23,5 +23,10 @@ namespace bbiwarg.Images
         public bool isEdgeAt(int x, int y) {
             return (image.Data[y,x,0] > 0);
         }
+
+        public Image<Gray, Byte> getImage()
+        {
+            return image;
+        }
     }
 }

+ 56 - 0
bbiwarg/Images/PalmImage.cs

@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Emgu.CV;
+using Emgu.CV.Structure;
+using System.Drawing;
+
+namespace bbiwarg.Images
+{
+    class PalmImage
+    {
+        private Image<Gray, Byte> image;
+        private int width, height;
+
+        public PalmImage(EdgeImage edgeImage)
+        {
+            image = edgeImage.getImage().Clone();
+            width = image.Width;
+            height = image.Height;
+
+            findContours();
+        }
+
+        private void findContours()
+        {
+            Image<Gray, Byte> storage = image.Clone();
+
+            MCvContour countour = new MCvContour();
+
+
+        }
+
+        public bool belongsToPalm(int x, int y)
+        {
+            return false;
+        }
+
+        private Point getPointWithDepth(Int16 depth)
+        {
+            for (int x = 0; x < width; ++x)
+            {
+                for (int y = 0; y < height; ++y)
+                {
+                    if (image.Data[y, x, 0] == depth)
+                        return new Point(x, y);
+                }
+            }
+            return new Point(0, 0);
+        }
+
+
+    }
+}

+ 7 - 0
bbiwarg/VideoHandle.cs

@@ -23,6 +23,7 @@ namespace bbiwarg
         private DepthImage depthImage;
         private EdgeImage edgeImage;
         private TouchImage touchImage;
+        private PalmImage palmImage;
 
         private FingerDetector fingerDetector;
         private TouchDetector touchDetector;
@@ -90,6 +91,10 @@ namespace bbiwarg
             return fingerDetector.isFingerPointAt(x, y);
         }
 
+        public bool isPalmPointAt(int x, int y) {
+            return palmImage.belongsToPalm(x, y);
+        }
+
         public TouchImageState getTouchImageStateAt(int x, int y) {
             return touchImage.getStateAt(x, y);
         }
@@ -124,6 +129,8 @@ namespace bbiwarg
 
             //track touchEvents
             touchTracker.setDetectedTouchEventsThisFrame(touchDetector.getTouchEvents(), touchImage);
+
+            palmImage = new PalmImage(edgeImage);
         }
     }
 }

+ 1 - 0
bbiwarg/bbiwarg.csproj

@@ -75,6 +75,7 @@
     <Compile Include="Graphics\OutputWindow.cs" />
     <Compile Include="Images\DepthImage.cs" />
     <Compile Include="Images\EdgeImage.cs" />
+    <Compile Include="Images\PalmImage.cs" />
     <Compile Include="Images\TouchImage.cs" />
     <Compile Include="InputProvider\InputFrame.cs" />
     <Compile Include="InputProvider\IInputProvider.cs" />