Преглед изворни кода

used public properties wherever possible

Alexander Hendrich пре 10 година
родитељ
комит
e78b31ce24

+ 5 - 5
bbiwarg/Detectors/Fingers/Finger.cs

@@ -11,17 +11,17 @@ namespace bbiwarg.Detectors.Fingers
 {
     class Finger
     {
-        private FingerSliceTrail sliceTrail;
-        public Vector2D Tip { get { return sliceTrail.Start.Mid; } }
-        public Vector2D Hand { get { return sliceTrail.End.Mid; } }
-        public LineSegment2D LineSegment { get { return sliceTrail.LineSegment; } }
-        public FingerSliceTrail SliceTrail { get { return sliceTrail; } private set { sliceTrail = value; } }
+        public Vector2D Tip { get { return SliceTrail.Start.Mid; } }
+        public Vector2D Hand { get { return SliceTrail.End.Mid; } }
+        public LineSegment2D LineSegment { get { return SliceTrail.LineSegment; } }
+        public FingerSliceTrail SliceTrail { get; private set; }
 
         public Finger(FingerSliceTrail sliceTrail)
         {
             SliceTrail = sliceTrail;
         }
 
+        //TODO: redo (not use similarity but actual distances and angle instead)
         public float getSimilarity(Finger compareFinger)
         {
             LineSegment2D compareLineSegment = compareFinger.LineSegment;

+ 11 - 12
bbiwarg/Detectors/Fingers/FingerDetector.cs

@@ -18,8 +18,7 @@ namespace bbiwarg.Detectors.Fingers
         private FingerImage fingerImage;
         private List<FingerSliceTrail> horizontalFingerSliceTrails;
         private List<FingerSliceTrail> verticalFingerSliceTrails;
-        private List<Finger> fingers;
-        public List<Finger> Fingers { get { return fingers; } private set { fingers = value; } }
+        public List<Finger> Fingers { get; private set; }
 
 
         public FingerDetector(DepthImage depthImage, EdgeImage edgeImage, FingerImage fingerImage)
@@ -38,8 +37,8 @@ namespace bbiwarg.Detectors.Fingers
 
             horizontalFingerSliceTrails = new List<FingerSliceTrail>();
 
-            int width = depthImage.getWidth();
-            int height = depthImage.getHeight();
+            int width = depthImage.Width;
+            int height = depthImage.Height;
 
             int minFingerSize = 10;
             int maxFingerSize = 30;
@@ -66,7 +65,7 @@ namespace bbiwarg.Detectors.Fingers
                                 if (fingerSlice.Size > minFingerSize && fingerSliceDepthTest(fingerSlice))
                                 {
                                     addHorizontalFingerSlice(fingerSlice);
-                                    fingerImage.drawLine(fingerSlice.Line, FingerImageState.possibleFingerSlice);
+                                    fingerImage.drawLine(fingerSlice.LineSegment, FingerImageState.possibleFingerSlice);
                                 }
                                 break;
                             }
@@ -84,8 +83,8 @@ namespace bbiwarg.Detectors.Fingers
         {
             verticalFingerSliceTrails = new List<FingerSliceTrail>();
 
-            int width = depthImage.getWidth();
-            int height = depthImage.getHeight();
+            int width = depthImage.Width;
+            int height = depthImage.Height;
 
             int minFingerSize = 10;
             int maxFingerSize = 30;
@@ -112,7 +111,7 @@ namespace bbiwarg.Detectors.Fingers
                                 if (fingerSlice.Size > minFingerSize && fingerSliceDepthTest(fingerSlice))
                                 {
                                     addVerticalFingerSlice(fingerSlice);
-                                    fingerImage.drawLine(fingerSlice.Line, FingerImageState.possibleFingerSlice);
+                                    fingerImage.drawLine(fingerSlice.LineSegment, FingerImageState.possibleFingerSlice);
                                 }
                                 break;
                             }
@@ -149,16 +148,16 @@ namespace bbiwarg.Detectors.Fingers
 
                     //filter double hits (horizontal+vertical finger)
                     bool addFinger = true;
-                    for (int i = fingers.Count - 1; i >= 0; i--)
+                    for (int i = Fingers.Count - 1; i >= 0; i--)
                     {
-                        Finger f = fingers[i];
+                        Finger f = Fingers[i];
                         Utility.LineSegment2D lineA = finger.LineSegment;
                         Utility.LineSegment2D lineB = f.LineSegment;
 
                         if(lineA.getVerticalDistanceTo(lineB) < 5 && lineA.getParallelDistanceTo(lineB) < 5)
                         {
                             if (finger.SliceTrail.NumSlices > f.SliceTrail.NumSlices)
-                                fingers.RemoveAt(i);
+                                Fingers.RemoveAt(i);
                             else
                                 addFinger = false;
                         }
@@ -166,7 +165,7 @@ namespace bbiwarg.Detectors.Fingers
 
                     if (addFinger)
                     {
-                        fingers.Add(finger);
+                        Fingers.Add(finger);
                         fingerImage.drawFinger(finger, FingerImageState.fingerDetected);
                     }
 

+ 4 - 7
bbiwarg/Detectors/Fingers/FingerSlice.cs

@@ -9,13 +9,10 @@ namespace bbiwarg.Detectors.Fingers
 {
     class FingerSlice
     {
-        private Vector2D start;
-        private Vector2D mid;
-        private Vector2D end;
-        public Vector2D Start { get { return start; } private set { start = value; } }
-        public Vector2D Mid { get { return mid; } private set { mid = value; } }
-        public Vector2D End { get { return end; } private set { end = value; } }
-        public LineSegment2D Line { get { return new LineSegment2D(Start, End); } }
+        public Vector2D Start { get; private set; }
+        public Vector2D Mid { get; private set; }
+        public Vector2D End { get; private set; }
+        public LineSegment2D LineSegment { get { return new LineSegment2D(Start, End); } }
         public float Size { get { return Start.getDistanceTo(End); } }
 
         public FingerSlice(Vector2D start, Vector2D end) {

+ 8 - 14
bbiwarg/Detectors/Fingers/FingerSliceTrail.cs

@@ -9,31 +9,25 @@ namespace bbiwarg.Detectors.Fingers
 {
     class FingerSliceTrail
     {
-        private List<FingerSlice> slices;
-        public FingerSlice Start { get { return slices[0]; } }
-        public FingerSlice End { get { return slices[slices.Count - 1]; } }
-        public FingerSlice this[int index] { get { return slices[index]; } }
-        public int NumSlices { get { return slices.Count; } }
+        public List<FingerSlice> Slices { get; private set; }
+        public FingerSlice Start { get { return Slices[0]; } }
+        public FingerSlice End { get { return Slices[Slices.Count - 1]; } }
+        public int NumSlices { get { return Slices.Count; } }
         public LineSegment2D LineSegment { get { return new LineSegment2D(Start.Mid, End.Mid); } }
 
         public FingerSliceTrail(FingerSlice slice)
         {
-            slices = new List<FingerSlice>();
-            slices.Add(slice);
+            Slices = new List<FingerSlice>();
+            Slices.Add(slice);
         }
 
         public void addSlice(FingerSlice slice)
         {
-            slices.Add(slice);
-        }
-
-        public List<FingerSlice> getSlices()
-        {
-            return slices;
+            Slices.Add(slice);
         }
 
         public void reverse() {
-            slices.Reverse();
+            Slices.Reverse();
         }
     }
 }

+ 4 - 7
bbiwarg/Detectors/Fingers/FingerTracker.cs

@@ -11,12 +11,13 @@ namespace bbiwarg.Detectors.Fingers
     {
         private FingerImage fingerImage;
         private List<Finger>[] detectedFingers;
-        private List<Finger> trackedFingers;
         private int framesUntilTracked;
+        public List<Finger> TrackedFingers { get; private set; }
 
         public FingerTracker() {
             framesUntilTracked = 3;
             detectedFingers = new List<Finger>[framesUntilTracked];
+            TrackedFingers = new List<Finger>();
 
             for (int i = 0; i < framesUntilTracked; i++)
             {
@@ -24,10 +25,6 @@ namespace bbiwarg.Detectors.Fingers
             }
         }
 
-        public List<Finger> getFingers() {
-            return trackedFingers;
-        }
-
         public void setDetectedTouchEventsThisFrame(List<Finger> detectedFingersThisFrame, FingerImage fingerImage)
         {
             this.fingerImage = fingerImage;
@@ -45,7 +42,7 @@ namespace bbiwarg.Detectors.Fingers
         private void findTrackedFingers()
         {
             float minSimilarity = 0.75f;
-            trackedFingers = new List<Finger>();
+            TrackedFingers = new List<Finger>();
 
             foreach (Finger finger in detectedFingers[0])
             {
@@ -64,7 +61,7 @@ namespace bbiwarg.Detectors.Fingers
                 if (tracked)
                 {
                     fingerImage.drawLine(finger.LineSegment, FingerImageState.fingerTracked);
-                    trackedFingers.Add(finger);
+                    TrackedFingers.Add(finger);
                 }
             }
         }

+ 12 - 14
bbiwarg/Detectors/Palm/PalmDetector.cs

@@ -30,7 +30,6 @@ namespace bbiwarg.Detectors.Palm
 
         private Contour<Point> palmContour;
         private List<MCvConvexityDefect> convexityDefects;
-        private Quadrangle palmQuad;
 
         private bool valid = false;
         private Vector2D topLeft;
@@ -38,15 +37,19 @@ namespace bbiwarg.Detectors.Palm
         private Vector2D bottomLeft;
         private Vector2D bottomRight;
 
+        public Quadrangle PalmQuad;
+
         public PalmDetector(DepthImage depthImage, EdgeImage edgeImage, List<Finger> detectedFingers, PalmImage palmImage)
         {
-            width = depthImage.getWidth();
-            height = depthImage.getHeight();
+            // TODO: determine which fingers are index or thumb-fingers and detect palm in thumb-hand
+
+            width = depthImage.Width;
+            height = depthImage.Height;
             this.depthImage = depthImage;
             this.edgeImage = edgeImage;
             this.palmImage = palmImage;
 
-            handImage = depthImage.getImage().Convert<Byte>(delegate(short s) { return (s == depthImage.getMaxDepth()) ? (byte)0 : (byte)1; });
+            handImage = depthImage.Image.Convert<Byte>(delegate(short s) { return (s == depthImage.getMaxDepth()) ? (byte)0 : (byte)1; });
 
             fingers = getFingersWithoutThumb(detectedFingers);
             buildPointingHandMask();
@@ -67,11 +70,6 @@ namespace bbiwarg.Detectors.Palm
             }
         }
 
-        public Quadrangle getPalmQuad()
-        {
-            return palmQuad;
-        }
-
         private List<Finger> getFingersWithoutThumb(List<Finger> detectedFingers)
         {
             Finger leftMost = null;
@@ -99,7 +97,7 @@ namespace bbiwarg.Detectors.Palm
         {
             foreach (Finger f in fingers)
             {
-                foreach (FingerSlice s in f.SliceTrail.getSlices())
+                foreach (FingerSlice s in f.SliceTrail.Slices)
                 {
                     image.Draw(new LineSegment2DF(s.Start, s.End), new Gray(val), 1);
                 }
@@ -227,13 +225,13 @@ namespace bbiwarg.Detectors.Palm
                     topLeft = bottomLeft + 1.2f * handLength - 0.3f * handWidth;
                 }
 
-                palmQuad = new Quadrangle(new Vector2D[] { bottomLeft, topLeft, topRight, bottomRight });
+                PalmQuad = new Quadrangle(new Vector2D[] { bottomLeft, topLeft, topRight, bottomRight });
 
                 valid = true;
             }
             else
             {
-                palmQuad = null;
+                PalmQuad = null;
                 valid = false;
             }
         }
@@ -242,9 +240,9 @@ namespace bbiwarg.Detectors.Palm
         {
             palmImage.drawContour(palmContour);
 
-            if (palmQuad != null)
+            if (PalmQuad != null)
             {
-                Vector2D[] vertices = palmQuad.Vertices;
+                Vector2D[] vertices = PalmQuad.Vertices;
                 for (int i = 0; i < 4; ++i)
                     palmImage.drawLine(new LineSegment2DF(vertices[i], vertices[(i + 1) % 4]), PalmImageState.palmRect);
 

+ 3 - 7
bbiwarg/Detectors/Touch/PalmTouchDetector.cs

@@ -11,23 +11,19 @@ namespace bbiwarg.Detectors.Touch
 {
     class PalmTouchDetector
     {
-        private List<PalmTouchEvent> palmTouchEvents;
+        public List<PalmTouchEvent> PalmTouchEvents { get; private set; }
 
         public PalmTouchDetector(List<TouchEvent> touchEvents, Quadrangle palmQuad) {
-            palmTouchEvents = new List<PalmTouchEvent>();
+            PalmTouchEvents = new List<PalmTouchEvent>();
 
             foreach (TouchEvent touchEvent in touchEvents) {
                 Vector2D relativePos = palmQuad.getRelativePosition(touchEvent.Position);
                 if (relativePos.X >= 0 && relativePos.X <= 1.0 && relativePos.Y >= 0 && relativePos.Y <= 1.0) {
                     PalmTouchEvent pte = new PalmTouchEvent(touchEvent.Position, relativePos, touchEvent.FloodValue, touchEvent.Finger);
-                    palmTouchEvents.Add(pte);
+                    PalmTouchEvents.Add(pte);
                 }
             }
 
         }
-
-        public List<PalmTouchEvent> getPalmTouchEvents() {
-            return palmTouchEvents;
-        }
     }
 }

+ 1 - 2
bbiwarg/Detectors/Touch/PalmTouchEvent.cs

@@ -11,8 +11,7 @@ namespace bbiwarg.Detectors.Touch
 {
     class PalmTouchEvent : TouchEvent
     {
-        private Vector2D _relativePalmPosition;
-        public Vector2D RelativePalmPosition { get { return _relativePalmPosition; } private set { _relativePalmPosition = value; } }
+        public Vector2D RelativePalmPosition { get; private set; }
 
         public PalmTouchEvent(Vector2D absolutePosition, Vector2D relativePalmPosition, float floodValue, Finger finger)
             : base(absolutePosition, floodValue, finger)

+ 7 - 11
bbiwarg/Detectors/Touch/TouchDetector.cs

@@ -18,13 +18,13 @@ namespace bbiwarg.Detectors.Touch
         private DepthImage depthImage;
         private TouchImage touchImage;
         private List<Finger> fingers;
-        private List<TouchEvent> touchEvents;
+        public List<TouchEvent> TouchEvents {get; private set;}
 
         public TouchDetector(List<Finger> fingers, DepthImage depthImage, TouchImage touchImage) {
             this.depthImage = depthImage;
             this.touchImage = touchImage;
             this.fingers = fingers;
-            this.touchEvents = new List<TouchEvent>();
+            this.TouchEvents = new List<TouchEvent>();
             float floodValueThreshold = 0.5f;
 
             foreach (Finger finger in fingers) {
@@ -36,21 +36,17 @@ namespace bbiwarg.Detectors.Touch
                     //correct touchEvent position
                     Vector2D direction = finger.LineSegment.Line.Direction;
                     float directionFactor = 10;
-                    float x = HelperFunctions.thresholdRange<float>(0, depthImage.getWidth() - 1, tipPoint.X + directionFactor * direction.X);
-                    float y = HelperFunctions.thresholdRange<float>(0, depthImage.getHeight() - 1, tipPoint.Y + directionFactor * direction.Y);
+                    float x = HelperFunctions.thresholdRange<float>(0, depthImage.Width - 1, tipPoint.X + directionFactor * direction.X);
+                    float y = HelperFunctions.thresholdRange<float>(0, depthImage.Height - 1, tipPoint.Y + directionFactor * direction.Y);
                     Vector2D tep = new Vector2D(x,y);
 
                     touchImage.setStateAt(tep, TouchImageState.touchDetected);
                     TouchEvent touchEvent = new TouchEvent(tep, floodValue, finger);
-                    touchEvents.Add(touchEvent);
+                    TouchEvents.Add(touchEvent);
                 }
             }
         }
 
-        public List<TouchEvent> getTouchEvents() {
-            return touchEvents;
-        }
-
         private float getFloodValue(Point touchPoint) {
             int searchSize = 15;
             int maxDepthDifference = 20;
@@ -58,9 +54,9 @@ namespace bbiwarg.Detectors.Touch
             Int16 depthAtTouch = (Int16) (depthImage.getDepthAt(touchPoint) + fingerDiameter);
 
             int minX = Math.Max(touchPoint.X - searchSize, 0);
-            int maxX = Math.Min(touchPoint.X + searchSize, depthImage.getWidth());
+            int maxX = Math.Min(touchPoint.X + searchSize, depthImage.Width);
             int minY = Math.Max(touchPoint.Y - searchSize, 0);
-            int maxY = Math.Min(touchPoint.Y + searchSize, depthImage.getHeight());
+            int maxY = Math.Min(touchPoint.Y + searchSize, depthImage.Height);
 
             int matchedPixels = 0;
             int countedPixels = 0;

+ 3 - 8
bbiwarg/Detectors/Touch/TouchEvent.cs

@@ -10,14 +10,9 @@ namespace bbiwarg.Detectors.Touch
 {
     class TouchEvent
     {
-        private Vector2D _position;
-        public Vector2D Position { get { return _position; } private set { _position = value; } }
-
-        private float _floodValue;
-        public float FloodValue { get { return _floodValue; } private set { _floodValue = value; } }
-
-        private Finger _finger;
-        public Finger Finger { get { return _finger; } private set { _finger = value; } }
+        public Vector2D Position { get; private set; }
+        public float FloodValue { get; private set; }
+        public Finger Finger { get; private set; }
 
         public TouchEvent(Vector2D position, float floodValue, Finger finger) {
             Position = position;

+ 3 - 7
bbiwarg/Detectors/Touch/TouchTracker.cs

@@ -11,8 +11,8 @@ namespace bbiwarg.Detectors.Touch
     {
         private TouchImage touchImage;
         private List<TouchEvent>[] detectedTouchEvents;
-        private List<TouchEvent> trackedTouchEvents;
         private int framesUntilTracked;
+        public List<TouchEvent> TrackedTouchEvents;
 
         public TouchTracker() {
             framesUntilTracked = 2;
@@ -23,10 +23,6 @@ namespace bbiwarg.Detectors.Touch
             }
         }
 
-        public List<TouchEvent> getTouchEvents() {
-            return trackedTouchEvents;
-        }
-
         public void setDetectedTouchEventsThisFrame(List<TouchEvent> touchEventsThisFrame, TouchImage touchImage) {
             this.touchImage = touchImage;
 
@@ -40,7 +36,7 @@ namespace bbiwarg.Detectors.Touch
         }
 
         private void findTrackedTouches() {
-            trackedTouchEvents = new List<TouchEvent>();
+            TrackedTouchEvents = new List<TouchEvent>();
 
             foreach (TouchEvent te in detectedTouchEvents[0]) {
                 bool tracked = true;
@@ -50,7 +46,7 @@ namespace bbiwarg.Detectors.Touch
                 if (tracked)
                 {
                     touchImage.setStateAt(te.Position, TouchImageState.touchTracked);
-                    trackedTouchEvents.Add(te);
+                    TrackedTouchEvents.Add(te);
                     //Console.WriteLine("touch tracked at x:" + te.getX() + " y:" + te.getY() + " [floodValue:" + te.getFloodValue() + "]");
                 }
             }

+ 7 - 7
bbiwarg/Graphics/OutputWindow.cs

@@ -22,7 +22,7 @@ namespace bbiwarg.Graphics
         private Stopwatch watch;
 
         public OutputWindow(VideoHandle videoHandle)
-            : base(3 * videoHandle.getWidth(), 2 * videoHandle.getHeight())
+            : base(3 * videoHandle.Width, 2 * videoHandle.Height)
         {
             this.videoHandle = videoHandle;
             watch = new Stopwatch();
@@ -135,13 +135,13 @@ namespace bbiwarg.Graphics
             }
 
             //draw textures
-            Int16[] depthTextureData = new Int16[3 * videoHandle.getWidth() * videoHandle.getHeight()];
-            Int16[] edgeTextureData = new Int16[3 * videoHandle.getWidth() * videoHandle.getHeight()];
+            Int16[] depthTextureData = new Int16[3 * videoHandle.Width * videoHandle.Height];
+            Int16[] edgeTextureData = new Int16[3 * videoHandle.Width * videoHandle.Height];
             int index = 0;
 
-            for (int y = 0; y < videoHandle.getHeight(); ++y)
+            for (int y = 0; y < videoHandle.Height; ++y)
             {
-                for (int x = 0; x < videoHandle.getWidth(); ++x)
+                for (int x = 0; x < videoHandle.Width; ++x)
                 {
                     Int16 red = 0;
                     Int16 green = 0;
@@ -231,7 +231,7 @@ namespace bbiwarg.Graphics
 
             GL.Enable(EnableCap.Texture2D);
             GL.BindTexture(TextureTarget.Texture2D, depthTextureID);
-            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb, videoHandle.getWidth(), videoHandle.getHeight(), 0, PixelFormat.Rgb, PixelType.Short, depthTextureData);
+            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb, videoHandle.Width, videoHandle.Height, 0, PixelFormat.Rgb, PixelType.Short, depthTextureData);
             float size = 0.5f;
             float size_2 = (float)(size / 2.0f);
             GL.Begin(PrimitiveType.Quads);
@@ -244,7 +244,7 @@ namespace bbiwarg.Graphics
 
             GL.Enable(EnableCap.Texture2D);
             GL.BindTexture(TextureTarget.Texture2D, edgeTextureID);
-            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb, videoHandle.getWidth(), videoHandle.getHeight(), 0, PixelFormat.Rgb, PixelType.Short, edgeTextureData);
+            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb, videoHandle.Width, videoHandle.Height, 0, PixelFormat.Rgb, PixelType.Short, edgeTextureData);
             GL.Begin(PrimitiveType.Quads);
             GL.Color3(1.0, 1.0, 1.0);
             GL.TexCoord2(0.0, 0.0); GL.Vertex3(0, -size / 2.0, -0.5);

+ 46 - 49
bbiwarg/Images/DepthImage.cs

@@ -11,90 +11,87 @@ namespace bbiwarg.Images
 {
     class DepthImage
     {
-        private int width;
-        private int height;
-        private Image<Gray, Int16> image;
-        private Int16 minDepth;
-        private Int16 maxDepth;
+        public Image<Gray, Int16> Image { get; private set; }
+        public int Width { get { return Image.Width; } }
+        public int Height { get { return Image.Height; } }
+        public Int16 MinDepth { get; private set; }
+        public Int16 MaxDepth { get; private set; }
 
-        public DepthImage(int width, int height, Image<Gray, Int16> image) {
-            this.width = width;
-            this.height = height;
-            this.image = image;
+        public DepthImage(Image<Gray, Int16> image)
+        {
+            this.Image = image;
 
             //smooth
-            this.image = image.SmoothMedian(3);
+            this.Image = image.SmoothMedian(3);
 
             //threshold min&maxDepth
-            minDepth = findMinDepth();
-            maxDepth = (Int16) (minDepth + 200);
-            thresholdDepth(minDepth, maxDepth);
+            MinDepth = findMinDepth();
+            MaxDepth = (Int16)(MinDepth + 200);
+            thresholdDepth(MinDepth, MaxDepth);
 
         }
 
-        public Int16 getDepthAt(Point point) {
+        public Int16 getDepthAt(Point point)
+        {
             return getDepthAt(point.X, point.Y);
         }
 
-        public Int16 getDepthAt(int x, int y) {
-            return image.Data[y, x, 0];
+        public Int16 getDepthAt(int x, int y)
+        {
+            return Image.Data[y, x, 0];
         }
 
-        public void setDepthAt(Point point, Int16 depth) {
+        public void setDepthAt(Point point, Int16 depth)
+        {
             setDepthAt(point.X, point.Y, depth);
         }
 
-        public void setDepthAt(int x, int y, Int16 depth) {
-            image.Data[y, x, 0] = depth;
+        public void setDepthAt(int x, int y, Int16 depth)
+        {
+            Image.Data[y, x, 0] = depth;
         }
 
-        public float getRelativeDepthAt(Point point) {
+        public float getRelativeDepthAt(Point point)
+        {
             return getRelativeDepthAt(point.X, point.Y);
         }
 
-        public float getRelativeDepthAt(int x, int y) {
-            float minMaxInterval = Math.Max(maxDepth - minDepth, 1);
-            return (getDepthAt(x, y)-minDepth) / minMaxInterval;
+        public float getRelativeDepthAt(int x, int y)
+        {
+            float minMaxInterval = Math.Max(MaxDepth - MinDepth, 1);
+            return (getDepthAt(x, y) - MinDepth) / minMaxInterval;
         }
 
-        public Int16 getMinDepth() {
-            return minDepth;
+        public Int16 getMinDepth()
+        {
+            return MinDepth;
         }
 
-        public Int16 getMaxDepth() {
-            return maxDepth;
+        public Int16 getMaxDepth()
+        {
+            return MaxDepth;
         }
 
-        public int getWidth() {
-            return width;
-        }
-
-        public int getHeight() {
-            return height;
-        }
-
-        public Image<Gray, Int16> getImage() {
-            return image;
-        }
-
-        private Int16 findMinDepth() {
-            minDepth = Int16.MaxValue;
-            for (int x = 0; x < width; ++x)
+        private Int16 findMinDepth()
+        {
+            MinDepth = Int16.MaxValue;
+            for (int x = 0; x < Width; ++x)
             {
-                for (int y = 0; y < height; ++y)
+                for (int y = 0; y < Height; ++y)
                 {
                     Int16 depth = getDepthAt(x, y);
-                    if (depth < minDepth)
-                        minDepth = depth;
+                    if (depth < MinDepth)
+                        MinDepth = depth;
                 }
             }
-            return minDepth;
+            return MinDepth;
         }
 
-        private void thresholdDepth(Int16 min, Int16 max) {
-            for (int x = 0; x < width; ++x)
+        private void thresholdDepth(Int16 min, Int16 max)
+        {
+            for (int x = 0; x < Width; ++x)
             {
-                for (int y = 0; y < height; ++y)
+                for (int y = 0; y < Height; ++y)
                 {
                     Int16 depth = getDepthAt(x, y);
                     if (depth > max || depth < min)

+ 1 - 1
bbiwarg/Images/EdgeImage.cs

@@ -15,7 +15,7 @@ namespace bbiwarg.Images
         public EdgeImage(DepthImage depthImage) {
             int minDepth = depthImage.getMinDepth();
             int maxDepth = depthImage.getMaxDepth();
-            Image<Gray, Int16> depthImageInt16 = depthImage.getImage();
+            Image<Gray, Int16> depthImageInt16 = depthImage.Image;
             Image<Gray, Byte> depthImageByte = depthImageInt16.Convert<Byte>(delegate(Int16 depth) { return (byte)(((depth - minDepth) * Byte.MaxValue) / (maxDepth - minDepth)); });
             image = depthImageByte.Canny(100, 75, 3);
         }

+ 1 - 1
bbiwarg/Images/FingerImage.cs

@@ -34,7 +34,7 @@ namespace bbiwarg.Images
         public void drawFinger(Finger finger, FingerImageState state) {
             FingerSliceTrail trail = finger.SliceTrail;
             for (int i = 0; i < trail.NumSlices; i++) {
-                drawLine(trail[i].Line, FingerImageState.fingerSlice);
+                drawLine(trail.Slices[i].LineSegment, FingerImageState.fingerSlice);
             }
             drawLine(finger.LineSegment, state);
         }

+ 0 - 2
bbiwarg/Images/TouchImage.cs

@@ -24,12 +24,10 @@ namespace bbiwarg.Images
     class TouchImage
     {
         private Image<Gray, byte> image;
-        private List<Vector2D> oldTouches;
 
         public TouchImage(int width, int height)
         {
             image = new Image<Gray, byte>(width, height);
-            oldTouches = new List<Vector2D>();
         }
 
         public void setStateAt(Point point, TouchImageState state) {

+ 8 - 16
bbiwarg/InputProvider/InputFrame.cs

@@ -11,8 +11,8 @@ namespace bbiwarg.InputProviders
 {
     class InputFrame
     {
-        private int width;
-        private int height;
+        public int Width { get; private set; }
+        public int Height { get; private set; }
         private int widthRawColor;
         private int heightRawColor;
         private Int16[] depthData;
@@ -21,8 +21,8 @@ namespace bbiwarg.InputProviders
         private byte[] rawColorData;
 
         public InputFrame(int width, int height, int widthRawColor, int heightRawColor, Int16[] depthData, Int16[] confidenceData, float[] uvData, byte[] rawColorData) {
-            this.width = width;
-            this.height = height;
+            this.Width = width;
+            this.Height = height;
             this.widthRawColor = widthRawColor;
             this.heightRawColor = heightRawColor;
             this.depthData = depthData;
@@ -31,30 +31,22 @@ namespace bbiwarg.InputProviders
             this.rawColorData = rawColorData;
         }
 
-        public int getWidth() {
-            return width;
-        }
-
-        public int getHeight() {
-            return height;
-        }
-
         public Int16 getDepthAt(int x, int y) {
-            return depthData[y * width + x];
+            return depthData[y * Width + x];
         }
 
         public Int16 getConfidenceAt(int x, int y) {
-            return confidenceData[y * width + x];
+            return confidenceData[y * Width + x];
         }
 
         public float getUAt(int x, int y)
         {
-            return uvData[2 * (y * width + x) + 0];
+            return uvData[2 * (y * Width + x) + 0];
         }
 
         public float getVAt(int x, int y)
         {
-            return uvData[2 * (y * width + x) + 1];
+            return uvData[2 * (y * Width + x) + 1];
         }
 
         public Color getColorAt(int x, int y) {

+ 3 - 6
bbiwarg/Utility/Quadrangle.cs

@@ -10,16 +10,13 @@ namespace bbiwarg.Utility
 {
     class Quadrangle
     {
+        public Vector2D[] Vertices { private set; get; }
+
         public Quadrangle(Vector2D[] vertices)
         {
             Vertices = vertices;
         }
 
-        public Vector2D[] Vertices
-        {
-            private set;
-            get;
-        }
 
         public Vector2D getRelativePosition(Vector2D p)
         {
@@ -34,7 +31,7 @@ namespace bbiwarg.Utility
 
             float D = B * B - 4 * A * C;
 
-            float u = (-B - (float) Math.Sqrt(D)) / (2 * A);
+            float u = (-B - (float)Math.Sqrt(D)) / (2 * A);
 
             float p1x = a.X + (b.X - a.X) * u;
             float p2x = d.X + (c.X - d.X) * u;

+ 16 - 26
bbiwarg/VideoHandle.cs

@@ -19,8 +19,8 @@ namespace bbiwarg
         private IInputProvider inputProvider;
         private InputFrame inputFrame;
 
-        private int width;
-        private int height;
+        public int Width { get; private set; }
+        public int Height { get; private set; }
         private DepthImage depthImage;
         private EdgeImage edgeImage;
         private PalmImage palmImage;
@@ -88,16 +88,6 @@ namespace bbiwarg
             }
         }
 
-        public int getWidth()
-        {
-            return width;
-        }
-
-        public int getHeight()
-        {
-            return height;
-        }
-
         public Int16 getDepthAt(int x, int y) {
             return depthImage.getDepthAt(x, y);
         }
@@ -125,30 +115,30 @@ namespace bbiwarg
 
         public List<PalmTouchEvent> getTouchEvents()
         {
-            return palmTouchDetector.getPalmTouchEvents();
+            return palmTouchDetector.PalmTouchEvents;
         }
 
         private void processFrameUpdate()
         {
             //read data from inputProvider
             inputFrame = inputProvider.getInputFrame();
-            width = inputFrame.getWidth();
-            height = inputFrame.getHeight();
+            Width = inputFrame.Width;
+            Height = inputFrame.Height;
 
             //create depthImage
-            Image<Gray, Int16> image = new Image<Gray, Int16>(width, height);
-            for (int x = 0; x < width; x++) {
-                for (int y = 0; y < height; y++) {
+            Image<Gray, Int16> image = new Image<Gray, Int16>(Width, Height);
+            for (int x = 0; x < Width; x++) {
+                for (int y = 0; y < Height; y++) {
                     image.Data[y, x, 0] = inputFrame.getDepthAt(x, y);
                 }
             }
-            depthImage = new DepthImage(width, height, image);
+            depthImage = new DepthImage(image);
 
             //create images
             edgeImage = new EdgeImage(depthImage);
-            touchImage = new TouchImage(width, height);
-            fingerImage = new FingerImage(width, height);
-            palmImage = new PalmImage(width, height);
+            touchImage = new TouchImage(Width, Height);
+            fingerImage = new FingerImage(Width, Height);
+            palmImage = new PalmImage(Width, Height);
 
             //detect+track fingers
             fingerDetector = new FingerDetector(depthImage, edgeImage, fingerImage);
@@ -158,10 +148,10 @@ namespace bbiwarg
             palmDetector = new PalmDetector(depthImage, edgeImage, fingerDetector.Fingers, palmImage);
 
             //detect+track touchEvents
-            touchDetector = new TouchDetector(fingerTracker.getFingers(), depthImage, touchImage);
-            if(palmDetector.getPalmQuad() != null)
-                palmTouchDetector = new PalmTouchDetector(touchDetector.getTouchEvents(), palmDetector.getPalmQuad());
-            touchTracker.setDetectedTouchEventsThisFrame(touchDetector.getTouchEvents(), touchImage);
+            touchDetector = new TouchDetector(fingerTracker.TrackedFingers, depthImage, touchImage);
+            if(palmDetector.PalmQuad != null)
+                palmTouchDetector = new PalmTouchDetector(touchDetector.TouchEvents, palmDetector.PalmQuad);
+            touchTracker.setDetectedTouchEventsThisFrame(touchDetector.TouchEvents, touchImage);
         }
     }
 }