Browse Source

new inputProvider (intel rs300)

Alexander Hendrich 7 years ago
parent
commit
60d262adc0

BIN
bbiwarg.v12.suo


+ 4 - 2
bbiwarg/BBWIWARG.cs

@@ -53,7 +53,7 @@ namespace BBIWARG
         /// <summary>
         /// the input provider
         /// </summary>
-        private InputProvider inputProvider;
+        private IInputProvider inputProvider;
 
         /// <summary>
         /// the tuio communicator
@@ -145,8 +145,10 @@ namespace BBIWARG
         {
             if (Parameters.InputSource == InputType.Movie)
                 inputProvider = new VideoInputProvider(Parameters.InputMoviePath);
+            else if (Parameters.InputSource == InputType.DS325)
+                inputProvider = new InputProviderIisu();
             else
-                inputProvider = new InputProvider();
+                inputProvider = new InputProviderIntel();
         }
 
         /// <summary>

+ 0 - 41
bbiwarg/Images/ConfidenceImage.cs

@@ -1,41 +0,0 @@
-using BBIWARG.Utility;
-using Emgu.CV;
-using Emgu.CV.Structure;
-using System;
-
-namespace BBIWARG.Images
-{
-    /// <summary>
-    /// ConfidenceImage stores the raw confidence data read from the Camera as an <see cref="Image"/>.
-    /// </summary>
-    public class ConfidenceImage
-    {
-        /// <summary>
-        /// the confidence image
-        /// </summary>
-        public Image<Gray, Int16> Image { get; private set; }
-
-        /// <summary>
-        /// a mask image, which is 1 iff the the confidence value is greater than <see cref="Parameters.ConfidenceImageMinThreshold"/>
-        /// </summary>
-        public Image<Gray, byte> Mask { get; private set; }
-
-        /// <summary>
-        /// the size of the confidence image
-        /// </summary>
-        public ImageSize Size { get; private set; }
-
-        /// <summary>
-        /// Constructs a new ConfidenceImage using the specified data and size.
-        /// </summary>
-        /// <param name="rawConfidenceData">pointer to raw confidence data</param>
-        /// <param name="size">size of the confidence image</param>
-        public ConfidenceImage(IntPtr rawConfidenceData, ImageSize size)
-        {
-            Size = size;
-            Image = new Image<Gray, Int16>(Size.Width, Size.Height, size.Width * 2, rawConfidenceData);
-
-            Mask = Image.ThresholdBinary(new Gray(Parameters.ConfidenceImageMinThreshold), new Gray(1)).Convert<Gray, byte>();
-        }
-    }
-}

+ 17 - 21
bbiwarg/Images/DepthImage.cs

@@ -19,12 +19,12 @@ namespace BBIWARG.Images
         /// <summary>
         /// the maximum depth which is considered important
         /// </summary>
-        public Int16 MaxDepth { get; private set; }
+        public UInt16 MaxDepth { get; private set; }
 
         /// <summary>
         /// the minimum depth in the raw depth image
         /// </summary>
-        public Int16 MinDepth { get; private set; }
+        public UInt16 MinDepth { get; private set; }
 
         /// <summary>
         /// image size of the depth image
@@ -38,20 +38,16 @@ namespace BBIWARG.Images
         /// <param name="rawDepthData">the raw depth data</param>
         /// <param name="size">the image size</param>
         /// <param name="confidenceImage">the confidence image</param>
-        public DepthImage(IntPtr rawDepthData, ImageSize size, ConfidenceImage confidenceImage)
+        public DepthImage(Image<Gray, UInt16> rawDepthImage)
         {
-            Size = size;
-            Image<Gray, Int16> rawDepthImage = new Image<Gray, Int16>(Size.Width, Size.Height, Size.Width * 2, rawDepthData);
-
-            // filter with confidenceImage mask
-            rawDepthImage = rawDepthImage.Or((1 - confidenceImage.Mask).Convert<Gray, Int16>().Mul(Int16.MaxValue));
-
+            Size = new ImageSize(rawDepthImage.Width, rawDepthImage.Height);
+            
             // smooth with median filter
             rawDepthImage = rawDepthImage.SmoothMedian(Parameters.DepthImageMedianSize);
 
             // threshold min&maxDepth
             MinDepth = findMinDepth(rawDepthImage);
-            MaxDepth = (Int16)(MinDepth + Parameters.DepthImageDepthRange);
+            MaxDepth = (UInt16)(MinDepth + Parameters.DepthImageDepthRange);
 
             // threshold (dst = (src > (MaxDepth - MinDepth)) ? MaxDepth - MinDepth : src)
             Image = (rawDepthImage - MinDepth).ThresholdTrunc(new Gray(MaxDepth - MinDepth)).Convert<Gray, byte>();
@@ -65,7 +61,7 @@ namespace BBIWARG.Images
         /// </summary>
         /// <param name="point">the point</param>
         /// <returns>depth at the point</returns>
-        public Int16 getDepthAt(Point point)
+        public UInt16 getDepthAt(Point point)
         {
             return getDepthAt(point.X, point.Y);
         }
@@ -76,15 +72,15 @@ namespace BBIWARG.Images
         /// <param name="x">x coordinate of the position</param>
         /// <param name="y">y coordinate of the position</param>
         /// <returns>the depth at the position</returns>
-        public Int16 getDepthAt(int x, int y)
+        public UInt16 getDepthAt(int x, int y)
         {
             try
             {
-                return (Int16)(MinDepth + Image.Data[y, x, 0]);
+                return (UInt16)(MinDepth + Image.Data[y, x, 0]);
             }
             catch (IndexOutOfRangeException e)
             {
-                return (Int16)(MinDepth + Image.Data[0, 0, 0]);
+                return (UInt16)(MinDepth + Image.Data[0, 0, 0]);
             }
         }
 
@@ -96,18 +92,18 @@ namespace BBIWARG.Images
         /// <param name="x">x coordinate of the position</param>
         /// <param name="y">y coordinate of the position</param>
         /// <returns>the depth at the position</returns>
-        public Int16 getDepthAtFixed(int x0, int y0, int x1, int y1)
+        public UInt16 getDepthAtFixed(int x0, int y0, int x1, int y1)
         {
             try
             {
                 int rx = (int) ((x1 - x0) * 0.15f + x0);
                 int ry = (int) ((y1 - y0) * 0.15f + y0);
 
-                return (Int16)(MinDepth + Image.Data[ry, rx, 0]);
+                return (UInt16)(MinDepth + Image.Data[ry, rx, 0]);
             }
             catch (IndexOutOfRangeException e)
             {
-                return (Int16)(MinDepth + Image.Data[0, 0, 0]);
+                return (UInt16)(MinDepth + Image.Data[0, 0, 0]);
             }
         }
 
@@ -116,7 +112,7 @@ namespace BBIWARG.Images
         /// </summary>
         /// <param name="point">point where the depth is set</param>
         /// <param name="depth">new depth value</param>
-        public void setDepthAt(Point point, Int16 depth)
+        public void setDepthAt(Point point, UInt16 depth)
         {
             setDepthAt(point.X, point.Y, depth);
         }
@@ -127,7 +123,7 @@ namespace BBIWARG.Images
         /// <param name="x">x coordinate of position to set depth</param>
         /// <param name="y">y coordinate of position to set depth</param>
         /// <param name="depth">new depth value</param>
-        public void setDepthAt(int x, int y, Int16 depth)
+        public void setDepthAt(int x, int y, UInt16 depth)
         {
             Image.Data[y, x, 0] = (byte)(depth - MinDepth);
         }
@@ -137,7 +133,7 @@ namespace BBIWARG.Images
         /// </summary>
         /// <param name="image">the image</param>
         /// <returns>the minimum depth</returns>
-        private Int16 findMinDepth(Image<Gray, Int16> image)
+        private UInt16 findMinDepth(Image<Gray, UInt16> image)
         {
             // min and max values
             double[] min, max;
@@ -147,7 +143,7 @@ namespace BBIWARG.Images
 
             image.MinMax(out min, out max, out minLoc, out maxLoc);
 
-            return (Int16)min[0];
+            return (UInt16)min[0];
         }
     }
 }

+ 0 - 5
bbiwarg/Input/InputHandling/FrameData.cs

@@ -13,11 +13,6 @@ namespace BBIWARG.Input.InputHandling
     /// </summary>
     public class FrameData
     {
-        /// <summary>
-        /// the confidence image read in this frame
-        /// </summary>
-        public ConfidenceImage ConfidenceImage { get; set; }
-
         /// <summary>
         /// the depth image read in this frame
         /// </summary>

+ 4 - 9
bbiwarg/Input/InputHandling/InputHandler.cs

@@ -45,7 +45,7 @@ namespace BBIWARG.Input.InputHandling
         /// <summary>
         /// the input provider which provides the raw data
         /// </summary>
-        private InputProvider inputProvider;
+        private IInputProvider inputProvider;
 
         /// <summary>
         /// the palm detector
@@ -93,10 +93,10 @@ namespace BBIWARG.Input.InputHandling
         public event NewProcessedFrameEventHandler NewProcessedFrameEvent;
 
         /// <summary>
-        /// Constructs an InputHandler with an <see cref="InputProvider"/>.
+        /// Constructs an InputHandler with an <see cref="InputProviderIisu"/>.
         /// </summary>
         /// <param name="inputProvider">the input provider</param>
-        public InputHandler(InputProvider inputProvider)
+        public InputHandler(IInputProvider inputProvider)
         {
             this.inputProvider = inputProvider;
             initialize();
@@ -125,14 +125,9 @@ namespace BBIWARG.Input.InputHandling
             frameData.ResetFlag = resetFlag;
             resetFlag = false;
 
-            // confidence image
-            Timer.start("InputHandler.handleNewFrame::createConfidenceImage");
-            frameData.ConfidenceImage = new ConfidenceImage(e.RawConfidenceData, ImageSize);
-            Timer.stop("InputHandler.handleNewFrame::createConfidenceImage");
-
             // depth image
             Timer.start("InputHandler.handleNewFrame::createDepthImage");
-            frameData.DepthImage = new DepthImage(e.RawDepthData, ImageSize, frameData.ConfidenceImage);
+            frameData.DepthImage = new DepthImage(e.DepthImageRaw);
             Timer.stop("InputHandler.handleNewFrame::createDepthImage");
 
             // edge image

+ 69 - 0
bbiwarg/Input/InputProviding/IInputProvider.cs

@@ -0,0 +1,69 @@
+using System;
+
+
+namespace BBIWARG.Input.InputProviding
+{
+    /// <summary>
+    /// signature for the event that the device started
+    /// </summary>
+    /// <param name="sender">sender of the event</param>
+    /// <param name="e">arguments of the event</param>
+    public delegate void DeviceStartedEventHandler(object sender, EventArgs e);
+
+    /// <summary>
+    /// signature for the event that a new frame is available
+    /// </summary>
+    /// <param name="sender">sender of the event</param>
+    /// <param name="e">arguments of the event</param>
+    public delegate void NewFrameEventHandler(object sender, NewFrameEventArgs e);
+
+    public interface IInputProvider
+    {
+
+
+        /// <summary>
+        /// the id of the current frame
+        /// </summary>
+        int CurrentFrameID { get; }
+
+        /// <summary>
+        /// the horizontal field of view angle
+        /// </summary>
+        float FieldOfViewHorizontal { get; }
+
+        /// <summary>
+        /// the vertical field of view angle
+        /// </summary>
+        float FieldOfViewVertical { get; }
+
+        /// <summary>
+        /// the height of all images
+        /// </summary>
+        int ImageHeight { get; }
+
+        /// <summary>
+        /// the width of all images
+        /// </summary>
+        int ImageWidth { get; }
+
+        /// <summary>
+        /// true iff the input source provides data
+        /// </summary>
+        bool IsActive { get; }
+
+        /// <summary>
+        /// event that the device started
+        /// </summary>
+        event DeviceStartedEventHandler DeviceStartedEvent;
+
+        /// <summary>
+        /// event that a new frame is available
+        /// </summary>
+        event NewFrameEventHandler NewFrameEvent;
+
+
+        void initialize();
+        void start();
+        void stop();
+    }
+}

+ 14 - 16
bbiwarg/Input/InputProviding/InputProvider.cs → bbiwarg/Input/InputProviding/InputProviderIisu.cs

@@ -1,26 +1,15 @@
 using Iisu;
 using System;
+using Emgu.CV;
+using Emgu.CV.Structure;
 
 namespace BBIWARG.Input.InputProviding
 {
-    /// <summary>
-    /// signature for the event that the device started
-    /// </summary>
-    /// <param name="sender">sender of the event</param>
-    /// <param name="e">arguments of the event</param>
-    public delegate void DeviceStartedEventHandler(object sender, EventArgs e);
-
-    /// <summary>
-    /// signature for the event that a new frame is available
-    /// </summary>
-    /// <param name="sender">sender of the event</param>
-    /// <param name="e">arguments of the event</param>
-    public delegate void NewFrameEventHandler(object sender, NewFrameEventArgs e);
 
     /// <summary>
     /// InputProvider provides the raw depth and confidence data through an event.
     /// </summary>
-    public class InputProvider
+    public class InputProviderIisu : IInputProvider
     {
         /// <summary>
         /// data handle for the raw confidence data
@@ -110,7 +99,7 @@ namespace BBIWARG.Input.InputProviding
         /// <summary>
         /// Constructs an InputProvider.
         /// </summary>
-        public InputProvider()
+        public InputProviderIisu()
         {
             IsActive = false;
         }
@@ -184,7 +173,16 @@ namespace BBIWARG.Input.InputProviding
         protected void provideNewFrame()
         {
             if (NewFrameEvent != null)
-                NewFrameEvent(this, new NewFrameEventArgs(CurrentFrameID, ImageWidth, ImageHeight, depthImage.Value.Raw, confidenceImage.Value.Raw));
+            {
+                Image<Gray, UInt16> rawDepthImage = new Image<Gray, UInt16>(ImageWidth, ImageHeight, ImageWidth * 2, depthImage.Value.Raw);
+                Image<Gray, UInt16> confidenceImage2 = new Image<Gray, UInt16>(ImageWidth, ImageHeight, ImageWidth * 2, confidenceImage.Value.Raw);
+
+                Image<Gray, byte> confidenceMask = confidenceImage2.ThresholdBinary(new Gray(Parameters.ConfidenceImageMinThreshold), new Gray(1)).Convert<Gray, byte>();
+
+                rawDepthImage = rawDepthImage.Or((1 - confidenceMask).Convert<Gray, UInt16>().Mul(UInt16.MaxValue));
+
+                NewFrameEvent(this, new NewFrameEventArgs(CurrentFrameID, rawDepthImage));
+            }
         }
 
         /// <summary>

+ 133 - 0
bbiwarg/Input/InputProviding/InputProviderIntel.cs

@@ -0,0 +1,133 @@
+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.Input.InputProviding
+{
+    class InputProviderIntel : IInputProvider
+    {
+        PXCMSenseManager senseManager;
+
+        public int CurrentFrameID
+        {
+            get;
+            private set;
+        }
+
+        public float FieldOfViewHorizontal
+        {
+            get;
+            private set;
+        }
+
+        public float FieldOfViewVertical
+        {
+            get;
+            private set;
+        }
+
+        public int ImageHeight
+        {
+            get;
+            private set;
+        }
+
+        public int ImageWidth
+        {
+            get;
+            private set;
+        }
+
+        public bool IsActive
+        {
+            get;
+            private set;
+        }
+
+        public event DeviceStartedEventHandler DeviceStartedEvent;
+
+        public event NewFrameEventHandler NewFrameEvent;
+
+        protected UInt16 lowConfidenceValue;
+
+        public void initialize()
+        {
+            CurrentFrameID = 0;
+        }
+
+        public void start()
+        {
+            senseManager = PXCMSenseManager.CreateInstance();
+            PXCMVideoModule.DataDesc ddesc = new PXCMVideoModule.DataDesc();
+            ddesc.deviceInfo.streams = PXCMCapture.StreamType.STREAM_TYPE_DEPTH;
+            senseManager.EnableStreams(ddesc);
+
+            senseManager.Init();
+
+            PXCMPointF32 fov = senseManager.captureManager.device.QueryDepthFieldOfView();
+            FieldOfViewHorizontal = fov.x;
+            FieldOfViewVertical = fov.y;
+
+            while (senseManager.AcquireFrame(true).IsError()) { }
+            PXCMImage.ImageInfo info = senseManager.QuerySample().depth.info;
+            ImageWidth = info.width;
+            ImageHeight = info.height;
+            senseManager.ReleaseFrame();
+
+            lowConfidenceValue = senseManager.captureManager.device.QueryDepthLowConfidenceValue();
+            senseManager.captureManager.device.SetDepthConfidenceThreshold((UInt16)Parameters.ConfidenceImageMinThreshold);
+
+            IsActive = true;
+
+            if (DeviceStartedEvent != null)
+                DeviceStartedEvent(this, new EventArgs());
+
+            run();
+        }
+
+        public void stop()
+        {
+            IsActive = false;
+        }
+
+        protected void run()
+        {
+            while (IsActive) {
+                if (senseManager.AcquireFrame(true).IsError())
+                    continue;
+
+                if (NewFrameEvent != null)
+                {
+
+                    PXCMCapture.Sample sample = senseManager.QuerySample();
+                    PXCMImage depthImage = sample.depth;
+                    PXCMImage.ImageInfo info = depthImage.info;
+                    PXCMImage.ImageData imageData;
+                    depthImage.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_DEPTH, out imageData);
+                    Bitmap dBmp = imageData.ToBitmap(0, info.width, info.height);
+                    depthImage.ReleaseAccess(imageData);
+                    depthImage.Dispose();
+
+                    Image<Gray, UInt16> dImg = new Image<Gray, UInt16>(dBmp);
+                    
+                    // confidence filter
+                    Image<Gray, byte> mask = dImg.InRange(new Gray(lowConfidenceValue), new Gray(lowConfidenceValue));
+                    dImg.SetValue(new Gray(UInt16.MaxValue), mask);
+
+                    NewFrameEvent(this, new NewFrameEventArgs(CurrentFrameID, dImg));
+                }
+
+                CurrentFrameID += 1;
+
+                senseManager.ReleaseFrame();
+            }
+
+            senseManager.Dispose();
+        }
+    }
+}

+ 7 - 20
bbiwarg/Input/InputProviding/NewFrameEventArgs.cs

@@ -1,4 +1,6 @@
 using System;
+using Emgu.CV;
+using Emgu.CV.Structure;
 
 namespace BBIWARG.Input.InputProviding
 {
@@ -15,38 +17,23 @@ namespace BBIWARG.Input.InputProviding
         /// <summary>
         /// the height of all images in the frame
         /// </summary>
-        public int Height { get; private set; }
+        public int Height { get { return DepthImageRaw.Height; } }
 
-        /// <summary>
-        /// pointer to the raw confidence data for the frame
-        /// </summary>
-        public IntPtr RawConfidenceData { get; private set; }
-
-        /// <summary>
-        /// pointer to the raw depth data for the frame
-        /// </summary>
-        public IntPtr RawDepthData { get; private set; }
+        public Image<Gray, UInt16> DepthImageRaw { get; private set; }
 
         /// <summary>
         /// the with of all images in the frame
         /// </summary>
-        public int Width { get; private set; }
+        public int Width { get { return DepthImageRaw.Width; } }
 
         /// <summary>
         /// Constructs a NewFrameEventArgs.
         /// </summary>
         /// <param name="frameID">frame id</param>
-        /// <param name="width">width of all images</param>
-        /// <param name="height">height of all images</param>
-        /// <param name="rawDepthData">pointer to raw depth data</param>
-        /// <param name="rawConfidenceData">pointer to raw confidence data</param>
-        public NewFrameEventArgs(int frameID, int width, int height, IntPtr rawDepthData, IntPtr rawConfidenceData)
+        public NewFrameEventArgs(int frameID, Image<Gray, UInt16> depthImageRaw)
         {
             FrameID = frameID;
-            Width = width;
-            Height = height;
-            RawDepthData = rawDepthData;
-            RawConfidenceData = rawConfidenceData;
+            DepthImageRaw = depthImageRaw;
         }
     }
 }

+ 1 - 1
bbiwarg/Input/InputProviding/VideoInputProvider.cs

@@ -14,7 +14,7 @@ namespace BBIWARG.Input.InputProviding
     /// <summary>
     /// VideoInputProvider provides the raw depth and confidence data read from a video file.
     /// </summary>
-    internal class VideoInputProvider : InputProvider
+    internal class VideoInputProvider : InputProviderIisu
     {
         /// <summary>
         /// parameter handle for the current frame of the movie

+ 2 - 2
bbiwarg/Output/DebugOutput/DebugWindow.cs

@@ -36,7 +36,7 @@ namespace BBIWARG.Output.DebugOutput
         /// <summary>
         /// the input provider
         /// </summary>
-        private InputProvider inputProvider;
+        private IInputProvider inputProvider;
 
         /// <summary>
         /// timer to periodically update the window
@@ -50,7 +50,7 @@ namespace BBIWARG.Output.DebugOutput
         /// <param name="inputHandler">input handle</param>
         /// <param name="name">the title of the window</param>
         /// <param name="updateInterval">the update interval for the window in milliseconds</param>
-        public DebugWindow(InputProvider inputProvider, InputHandler inputHandler, String name, int updateInterval)
+        public DebugWindow(IInputProvider inputProvider, InputHandler inputHandler, String name, int updateInterval)
         {
             InitializeComponent();
 

+ 2 - 2
bbiwarg/Output/GlassesOutput/GlassesWindow.cs

@@ -48,7 +48,7 @@ namespace BBIWARG.Output.GlassesOutput
         /// <summary>
         /// the input provider
         /// </summary>
-        private InputProvider inputProvider;
+        private IInputProvider inputProvider;
 
         /// <summary>
         /// size of the input images
@@ -83,7 +83,7 @@ namespace BBIWARG.Output.GlassesOutput
         /// <param name="name">title of the window</param>
         /// <param name="screen">the screen this window is shown on</param>
         /// <param name="updateInterval">the update interval for the window in milliseconds</param>
-        public GlassesWindow(InputProvider inputProvider, InputHandler inputHandler, String name, Screen screen, int updateInterval)
+        public GlassesWindow(IInputProvider inputProvider, InputHandler inputHandler, String name, Screen screen, int updateInterval)
         {
             InitializeComponent();
 

+ 3 - 2
bbiwarg/Parameters.cs

@@ -10,7 +10,8 @@ namespace BBIWARG
     /// </summary>
     public enum InputType
     {
-        Camera,
+        RS300,
+        DS325,
         Movie
     }
 
@@ -43,7 +44,7 @@ namespace BBIWARG
         /// <summary>
         /// the input source type
         /// </summary>
-        public static readonly InputType InputSource = InputType.Camera;
+        public static readonly InputType InputSource = InputType.DS325;
 
         #endregion input
 

+ 8 - 8
bbiwarg/Recognition/FingerRecognition/FingerDetector.cs

@@ -169,7 +169,7 @@ namespace BBIWARG.Recognition.FingerRecognition
         {
             if (edgeImageAdapted.isRoughEdgeAt(position)) return null;
 
-            Int16 depth = depthImage.getDepthAt(position);
+            UInt16 depth = depthImage.getDepthAt(position);
             int maxWidth2D = (int)coordinateConverter.convertLength3Dto2D(Parameters.FingerMaxWidth3D, depth);
 
             Vector2D dirStart = direction.getOrthogonal(reversed);
@@ -200,7 +200,7 @@ namespace BBIWARG.Recognition.FingerRecognition
         {
             Vector2D searchStart = start + Parameters.FingerMinWidth2D * direction;
 
-            Int16 depth = depthImage.getDepthAt(start);
+            UInt16 depth = depthImage.getDepthAt(start);
             int maxWidth2D = (int)coordinateConverter.convertLength3Dto2D(Parameters.FingerMaxWidth3D, depth);
 
             Vector2D end = edgeImageAdapted.findNextRoughEdge(searchStart, direction, maxWidth2D);
@@ -253,9 +253,9 @@ namespace BBIWARG.Recognition.FingerRecognition
         /// <returns>whether the slice is located on a finger</returns>
         private bool fingerSliceDepthTest(FingerSlice slice)
         {
-            Int16 depthStart = depthImage.getDepthAt(slice.Start.moveWithinBound(depthImage.Size, slice.Direction.getInverse(), Parameters.FingerContourMargin));
-            Int16 depthMid = depthImage.getDepthAt(slice.Mid);
-            Int16 depthEnd = depthImage.getDepthAt(slice.End.moveWithinBound(depthImage.Size, slice.Direction, Parameters.FingerContourMargin));
+            UInt16 depthStart = depthImage.getDepthAt(slice.Start.moveWithinBound(depthImage.Size, slice.Direction.getInverse(), Parameters.FingerContourMargin));
+            UInt16 depthMid = depthImage.getDepthAt(slice.Mid);
+            UInt16 depthEnd = depthImage.getDepthAt(slice.End.moveWithinBound(depthImage.Size, slice.Direction, Parameters.FingerContourMargin));
             return depthStart > depthMid && depthMid < depthEnd;
         }
 
@@ -287,9 +287,9 @@ namespace BBIWARG.Recognition.FingerRecognition
             Vector2D out1 = midSlice.Start.moveWithinBound(depthImage.Size, midSlice.Direction.getInverse(), Parameters.FingerOutMargin);
             Vector2D out2 = midSlice.End.moveWithinBound(depthImage.Size, midSlice.Direction, Parameters.FingerOutMargin);
 
-            Int16 depthAtFinger = depthImage.getDepthAt(finger.MidPoint);
-            Int16 depthAtOut1 = depthImage.getDepthAt(out1);
-            Int16 depthAtOut2 = depthImage.getDepthAt(out2);
+            UInt16 depthAtFinger = depthImage.getDepthAt(finger.MidPoint);
+            UInt16 depthAtOut1 = depthImage.getDepthAt(out1);
+            UInt16 depthAtOut2 = depthImage.getDepthAt(out2);
             int minDepthDifference = Math.Min(Math.Abs(depthAtFinger - depthAtOut1), Math.Abs(depthAtFinger - depthAtOut2));
 
             return minDepthDifference < Parameters.FingerMaxCrippleDifference;

+ 4 - 4
bbiwarg/Recognition/HandRecognition/HandDetector.cs

@@ -66,7 +66,7 @@ namespace BBIWARG.Recognition.HandRecognition
 
             foreach (Finger finger in fingers)
             {
-                Int16 depthAtHand = depthImage.getDepthAt(finger.HandPoint);
+                UInt16 depthAtHand = depthImage.getDepthAt(finger.HandPoint);
                 Point[] contour = finger.getContour(0f).ToArray();
                 modifiedHandDepthImage.DrawPolyline(contour, false, new Gray(depthAtHand), 1);
             }
@@ -89,12 +89,12 @@ namespace BBIWARG.Recognition.HandRecognition
                         FingerSlice midSlice = overlappingFinger.SliceTrail.MidSlice;
                         Vector2D midOut1 = midSlice.Start.moveWithinBound(depthImage.Size, midSlice.Direction.getInverse(), Parameters.FingerOutMargin);
                         Vector2D midOut2 = midSlice.End.moveWithinBound(depthImage.Size, midSlice.Direction, Parameters.FingerOutMargin);
-                        Int16 depthAtMidOut1 = depthImage.getDepthAt(midOut1);
-                        Int16 depthAtMidOut2 = depthImage.getDepthAt(midOut2);
+                        UInt16 depthAtMidOut1 = depthImage.getDepthAt(midOut1);
+                        UInt16 depthAtMidOut2 = depthImage.getDepthAt(midOut2);
                         bool midOut1InHand = hand.isInside(midOut1);
                         bool midOut2InHand = hand.isInside(midOut2);
 
-                        Int16 maxDepth = depthImage.MaxDepth;
+                        UInt16 maxDepth = depthImage.MaxDepth;
                         if (midOut1InHand != midOut2InHand && depthAtMidOut1 != maxDepth && depthAtMidOut2 != maxDepth && Math.Abs(depthAtMidOut1 - depthAtMidOut2) < Parameters.HandExtendMaxDifference)
                         {
                             Vector2D handPoint, handExtensionPoint;

+ 6 - 2
bbiwarg/bbiwarg.csproj

@@ -91,6 +91,9 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>lib\iisuNet.dll</HintPath>
     </Reference>
+    <Reference Include="libpxcclr.cs">
+      <HintPath>..\..\..\..\..\..\Program Files (x86)\Intel\RSSDK\bin\win32\libpxcclr.cs.dll</HintPath>
+    </Reference>
     <Reference Include="MathNet.Numerics">
       <HintPath>lib\MathNet.Numerics.dll</HintPath>
     </Reference>
@@ -115,6 +118,8 @@
     <Compile Include="API\Server.cs" />
     <Compile Include="API\Slider.cs" />
     <Compile Include="Input\InputHandling\NewProcessedFrameEventArgs.cs" />
+    <Compile Include="Input\InputProviding\InputProviderIntel.cs" />
+    <Compile Include="Input\InputProviding\IInputProvider.cs" />
     <Compile Include="Input\InputProviding\NewFrameEventArgs.cs" />
     <Compile Include="Output\GlassesOutput\GlassesWindow.cs">
       <SubType>Form</SubType>
@@ -142,7 +147,7 @@
     <Compile Include="Utility\Projection2DTo2D.cs" />
     <Compile Include="Parameters.cs" />
     <Compile Include="Input\InputHandling\InputHandler.cs" />
-    <Compile Include="Input\InputProviding\InputProvider.cs" />
+    <Compile Include="Input\InputProviding\InputProviderIisu.cs" />
     <Compile Include="Input\InputProviding\VideoInputProvider.cs" />
     <Compile Include="Recognition\FingerRecognition\Finger.cs" />
     <Compile Include="Recognition\FingerRecognition\FingerDetector.cs" />
@@ -162,7 +167,6 @@
     <Compile Include="Recognition\TouchRecognition\Touch.cs" />
     <Compile Include="Recognition\TouchRecognition\TouchTracker.cs" />
     <Compile Include="Output\DebugOutput\TouchEventVisualizer.cs" />
-    <Compile Include="Images\ConfidenceImage.cs" />
     <Compile Include="Images\DepthImage.cs" />
     <Compile Include="Images\EdgeImage.cs" />
     <Compile Include="Output\OutputImage.cs" />