Browse Source

autoformat on all files

Alexander Hendrich 10 years ago
parent
commit
d1a6fdd88e

+ 2 - 2
bbiwarg/Images/DepthImage.cs

@@ -56,14 +56,14 @@ namespace bbiwarg.Images
 
 
             // smooth with median filter
             // smooth with median filter
             rawDepthImage = rawDepthImage.SmoothMedian(Parameters.DepthImageMedianSize);
             rawDepthImage = rawDepthImage.SmoothMedian(Parameters.DepthImageMedianSize);
-            
+
             // threshold min&maxDepth
             // threshold min&maxDepth
             MinDepth = findMinDepth(rawDepthImage);
             MinDepth = findMinDepth(rawDepthImage);
             MaxDepth = (Int16)(MinDepth + Parameters.DepthImageDepthRange);
             MaxDepth = (Int16)(MinDepth + Parameters.DepthImageDepthRange);
 
 
             // threshold (dst = (src > (MaxDepth - MinDepth)) ? MaxDepth - MinDepth : src)
             // threshold (dst = (src > (MaxDepth - MinDepth)) ? MaxDepth - MinDepth : src)
             Image = (rawDepthImage - MinDepth).ThresholdTrunc(new Gray(MaxDepth - MinDepth)).Convert<Gray, byte>();
             Image = (rawDepthImage - MinDepth).ThresholdTrunc(new Gray(MaxDepth - MinDepth)).Convert<Gray, byte>();
-            
+
             // smooth with median filter
             // smooth with median filter
             Image = Image.SmoothMedian(Parameters.DepthImageMedianSize);
             Image = Image.SmoothMedian(Parameters.DepthImageMedianSize);
         }
         }

+ 3 - 3
bbiwarg/Input/InputHandling/FrameData.cs

@@ -58,7 +58,7 @@ namespace bbiwarg.Input.InputHandling
         /// </summary>
         /// </summary>
         public List<Finger> TrackedFingers { get; set; }
         public List<Finger> TrackedFingers { get; set; }
 
 
-        
+
         /// <summary>
         /// <summary>
         /// a list of hands detected in this frame
         /// a list of hands detected in this frame
         /// </summary>
         /// </summary>
@@ -69,7 +69,7 @@ namespace bbiwarg.Input.InputHandling
         /// </summary>
         /// </summary>
         public List<Hand> TrackedHands { get; set; }
         public List<Hand> TrackedHands { get; set; }
 
 
-        
+
         /// <summary>
         /// <summary>
         /// a list of plams detected in this frame
         /// a list of plams detected in this frame
         /// </summary>
         /// </summary>
@@ -80,7 +80,7 @@ namespace bbiwarg.Input.InputHandling
         /// </summary>
         /// </summary>
         public List<Palm> TrackedPalms { get; set; }
         public List<Palm> TrackedPalms { get; set; }
 
 
-        
+
         /// <summary>
         /// <summary>
         /// a list of <see cref="Touch"/> objects detected in this frame
         /// a list of <see cref="Touch"/> objects detected in this frame
         /// </summary>
         /// </summary>

+ 1 - 1
bbiwarg/Input/InputHandling/InputHandler.cs

@@ -19,7 +19,7 @@ namespace bbiwarg.Input.InputHandling
     /// <summary>
     /// <summary>
     /// Encapsulates the arguments for the event of finishing to process a new frame.
     /// Encapsulates the arguments for the event of finishing to process a new frame.
     /// </summary>
     /// </summary>
-    public class NewProcessedFrameEventArgs: EventArgs
+    public class NewProcessedFrameEventArgs : EventArgs
     {
     {
         /// <summary>
         /// <summary>
         /// the data of the processed frame
         /// the data of the processed frame

+ 5 - 3
bbiwarg/Input/InputProviding/VideoInputProvider.cs

@@ -128,8 +128,10 @@ namespace bbiwarg.Input.InputProviding
         /// <summary>
         /// <summary>
         /// Provides the main loop for reading data from the video file.
         /// Provides the main loop for reading data from the video file.
         /// </summary>
         /// </summary>
-        protected override void run() {
-            while (IsActive) {
+        protected override void run()
+        {
+            while (IsActive)
+            {
                 if (!IsPaused)
                 if (!IsPaused)
                     nextFrame();
                     nextFrame();
                 else
                 else
@@ -144,7 +146,7 @@ namespace bbiwarg.Input.InputProviding
         {
         {
             base.nextFrame();
             base.nextFrame();
 
 
-            if(CurrentFrameID == 0 && MovieRestartedEvent != null)
+            if (CurrentFrameID == 0 && MovieRestartedEvent != null)
                 MovieRestartedEvent(this, new EventArgs());
                 MovieRestartedEvent(this, new EventArgs());
         }
         }
     }
     }

+ 3 - 2
bbiwarg/Output/DebugOutput/DebugImageCreator.cs

@@ -181,7 +181,7 @@ namespace bbiwarg.Output.DebugOutput
 
 
             foreach (Palm p in frameData.TrackedPalms)
             foreach (Palm p in frameData.TrackedPalms)
                 PalmImage.drawQuadrangleGrid(p.Quad, Parameters.PalmQuadColor, Parameters.PalmGridColor, numRows, numColumns);
                 PalmImage.drawQuadrangleGrid(p.Quad, Parameters.PalmQuadColor, Parameters.PalmGridColor, numRows, numColumns);
-            
+
             // border
             // border
             PalmImage.drawBorder(Parameters.OutputImageBorderColor);
             PalmImage.drawBorder(Parameters.OutputImageBorderColor);
         }
         }
@@ -192,7 +192,8 @@ namespace bbiwarg.Output.DebugOutput
         /// <param name="frameData">data for the new frame</param>
         /// <param name="frameData">data for the new frame</param>
         /// <param name="numRows">number of rows in the palm grid</param>
         /// <param name="numRows">number of rows in the palm grid</param>
         /// <param name="numColumns">number of columns in the palm grid</param>
         /// <param name="numColumns">number of columns in the palm grid</param>
-        private void updateTouchImage(FrameData frameData, int numRows, int numColumns) {
+        private void updateTouchImage(FrameData frameData, int numRows, int numColumns)
+        {
             if (TouchImage != null)
             if (TouchImage != null)
                 TouchImage.Dispose();
                 TouchImage.Dispose();
 
 

+ 16 - 9
bbiwarg/Output/DebugOutput/DebugWindow.cs

@@ -108,8 +108,10 @@ namespace bbiwarg.Output.DebugOutput
                 Close();
                 Close();
 
 
             FrameData frameData = inputHandler.FrameData;
             FrameData frameData = inputHandler.FrameData;
-            if (frameData != null) {
-                lock (frameData) {
+            if (frameData != null)
+            {
+                lock (frameData)
+                {
                     if (currentFrameID != frameData.FrameID)
                     if (currentFrameID != frameData.FrameID)
                     {
                     {
                         currentFrameID = frameData.FrameID;
                         currentFrameID = frameData.FrameID;
@@ -126,7 +128,7 @@ namespace bbiwarg.Output.DebugOutput
                 updateGUI();
                 updateGUI();
                 Utility.Timer.stop("DebugWindow.update::updateGUI");
                 Utility.Timer.stop("DebugWindow.update::updateGUI");
             }
             }
-            
+
             Utility.Timer.stop("DebugWindow.update");
             Utility.Timer.stop("DebugWindow.update");
         }
         }
 
 
@@ -134,18 +136,20 @@ namespace bbiwarg.Output.DebugOutput
         /// Updates the debug images.
         /// Updates the debug images.
         /// </summary>
         /// </summary>
         /// <param name="frameData">data for the new frame</param>
         /// <param name="frameData">data for the new frame</param>
-        private void updateImages(FrameData frameData) {
+        private void updateImages(FrameData frameData)
+        {
             guiUpToDate = false;
             guiUpToDate = false;
 
 
             int numRows = palmGridNumRowsTrackBar.Value;
             int numRows = palmGridNumRowsTrackBar.Value;
             int numColumns = palmGridNumColumnsTrackBar.Value;
             int numColumns = palmGridNumColumnsTrackBar.Value;
-            debugImageCreator.updateImages(frameData, numRows, numColumns);            
+            debugImageCreator.updateImages(frameData, numRows, numColumns);
         }
         }
 
 
         /// <summary>
         /// <summary>
         /// Updates the gui elements.
         /// Updates the gui elements.
         /// </summary>
         /// </summary>
-        private void updateGUI() {
+        private void updateGUI()
+        {
             // update image boxes
             // update image boxes
             depthImageBox.Image = debugImageCreator.DepthImage;
             depthImageBox.Image = debugImageCreator.DepthImage;
             fingerImageBox.Image = debugImageCreator.FingerImage;
             fingerImageBox.Image = debugImageCreator.FingerImage;
@@ -192,7 +196,8 @@ namespace bbiwarg.Output.DebugOutput
         /// <summary>
         /// <summary>
         /// Toggles the paused state of the movie.
         /// Toggles the paused state of the movie.
         /// </summary>
         /// </summary>
-        private void handlePlayPause() {
+        private void handlePlayPause()
+        {
             VideoInputProvider videoInputProvider = inputProvider as VideoInputProvider;
             VideoInputProvider videoInputProvider = inputProvider as VideoInputProvider;
 
 
             if (videoInputProvider.IsPaused)
             if (videoInputProvider.IsPaused)
@@ -202,7 +207,8 @@ namespace bbiwarg.Output.DebugOutput
                 nextFrameButton.Enabled = false;
                 nextFrameButton.Enabled = false;
                 previousFrameButton.Enabled = false;
                 previousFrameButton.Enabled = false;
             }
             }
-            else {
+            else
+            {
                 videoInputProvider.pause();
                 videoInputProvider.pause();
                 playPauseButton.Text = "Play";
                 playPauseButton.Text = "Play";
                 nextFrameButton.Enabled = true;
                 nextFrameButton.Enabled = true;
@@ -213,7 +219,8 @@ namespace bbiwarg.Output.DebugOutput
         /// <summary>
         /// <summary>
         /// Jumps to the next movie frame.
         /// Jumps to the next movie frame.
         /// </summary>
         /// </summary>
-        private void handleGoToNextFrame() {
+        private void handleGoToNextFrame()
+        {
             VideoInputProvider videoInputProvider = inputProvider as VideoInputProvider;
             VideoInputProvider videoInputProvider = inputProvider as VideoInputProvider;
             videoInputProvider.goToNextFrame();
             videoInputProvider.goToNextFrame();
         }
         }

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

@@ -80,7 +80,7 @@ namespace bbiwarg.Output.DebugOutput
         public void handleNewFrameData(object sender, NewProcessedFrameEventArgs e)
         public void handleNewFrameData(object sender, NewProcessedFrameEventArgs e)
         {
         {
             FrameData frameData = e.FrameData;
             FrameData frameData = e.FrameData;
-            lock (frameData) lock (sync) 
+            lock (frameData) lock (sync)
                 {
                 {
                     if (frameData.ResetFlag)
                     if (frameData.ResetFlag)
                         reset();
                         reset();
@@ -159,7 +159,7 @@ namespace bbiwarg.Output.DebugOutput
 
 
                         int x = (int)((col + 0.5f) * widthPerColumn) - 5;
                         int x = (int)((col + 0.5f) * widthPerColumn) - 5;
                         int y = (int)((row + 0.5f) * heightPerRow) + 5;
                         int y = (int)((row + 0.5f) * heightPerRow) + 5;
-                        outputImage.drawText(new Point(x,y), index.ToString(), Parameters.TouchEventVisualizerTextColor);
+                        outputImage.drawText(new Point(x, y), index.ToString(), Parameters.TouchEventVisualizerTextColor);
                         index++;
                         index++;
                     }
                     }
                 }
                 }

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

@@ -250,7 +250,7 @@ namespace bbiwarg.Output.GlassesOutput
                         {
                         {
                             Vector2D pointOutput = currentCalibrationPoint;
                             Vector2D pointOutput = currentCalibrationPoint;
                             Vector2D pointInput = frameData.TrackedFingers[0].TipPoint;
                             Vector2D pointInput = frameData.TrackedFingers[0].TipPoint;
-                            
+
                             projection.addCalibrationPoints(pointInput, pointOutput);
                             projection.addCalibrationPoints(pointInput, pointOutput);
 
 
                             currentCalibrationPoint = getRandomOutputPoint();
                             currentCalibrationPoint = getRandomOutputPoint();

+ 6 - 6
bbiwarg/Parameters.cs

@@ -25,7 +25,7 @@ namespace bbiwarg
     static class Parameters
     static class Parameters
     {
     {
         #region console
         #region console
-        
+
         /// <summary>
         /// <summary>
         /// with of the console in monospace characters
         /// with of the console in monospace characters
         /// </summary>
         /// </summary>
@@ -35,12 +35,12 @@ namespace bbiwarg
         /// height of the console in monospace characters
         /// height of the console in monospace characters
         /// </summary>
         /// </summary>
         public static readonly int ConsoleHeight = 30;
         public static readonly int ConsoleHeight = 30;
-        
+
         #endregion
         #endregion
 
 
 
 
         #region input
         #region input
-        
+
         /// <summary>
         /// <summary>
         /// the input source type
         /// the input source type
         /// </summary>
         /// </summary>
@@ -185,7 +185,7 @@ namespace bbiwarg
 
 
 
 
         #region general tracking
         #region general tracking
-        
+
         /// <summary>
         /// <summary>
         /// if a tracked object moves this relative amount it will have a similarity of 0 to itself at the previous position
         /// if a tracked object moves this relative amount it will have a similarity of 0 to itself at the previous position
         /// </summary>
         /// </summary>
@@ -300,7 +300,7 @@ namespace bbiwarg
 
 
 
 
         #region hand detection
         #region hand detection
-        
+
         /// <summary>
         /// <summary>
         /// number of colors used to draw hands
         /// number of colors used to draw hands
         /// </summary>
         /// </summary>
@@ -593,7 +593,7 @@ namespace bbiwarg
 
 
 
 
         #region images
         #region images
-        
+
         /// <summary>
         /// <summary>
         /// color used to specify which color channels the depth image is drawn to
         /// color used to specify which color channels the depth image is drawn to
         /// </summary>
         /// </summary>

+ 4 - 2
bbiwarg/Recognition/FingerRecognition/Finger.cs

@@ -73,7 +73,8 @@ namespace bbiwarg.Recognition.FingerRecognition
         /// <summary>
         /// <summary>
         /// Reverses the finger (start<->end)
         /// Reverses the finger (start<->end)
         /// </summary>
         /// </summary>
-        public void reverse() {
+        public void reverse()
+        {
             SliceTrail.reverse();
             SliceTrail.reverse();
         }
         }
 
 
@@ -82,7 +83,8 @@ namespace bbiwarg.Recognition.FingerRecognition
         /// </summary>
         /// </summary>
         /// <param name="margin">the margin around the finger (distance in pixels)</param>
         /// <param name="margin">the margin around the finger (distance in pixels)</param>
         /// <returns>the contour of the finger</returns>
         /// <returns>the contour of the finger</returns>
-        public Contour<Point> getContour(float margin) {
+        public Contour<Point> getContour(float margin)
+        {
             return SliceTrail.getContour(margin);
             return SliceTrail.getContour(margin);
         }
         }
     }
     }

+ 5 - 4
bbiwarg/Recognition/FingerRecognition/FingerDetector.cs

@@ -47,10 +47,11 @@ namespace bbiwarg.Recognition.FingerRecognition
         /// Initializes a new instance of the FingerDetector class.
         /// Initializes a new instance of the FingerDetector class.
         /// </summary>
         /// </summary>
         /// <param name="coordinateConverter">The coordinate converter.</param>
         /// <param name="coordinateConverter">The coordinate converter.</param>
-        public FingerDetector(CoordinateConverter coordinateConverter) {
+        public FingerDetector(CoordinateConverter coordinateConverter)
+        {
             this.coordinateConverter = coordinateConverter;
             this.coordinateConverter = coordinateConverter;
         }
         }
-        
+
         /// <summary>
         /// <summary>
         /// Detects fingers in the current frame using the depth and edge image. Afterwards the detected fingers are stored in the given frame data (detectedFingers).
         /// Detects fingers in the current frame using the depth and edge image. Afterwards the detected fingers are stored in the given frame data (detectedFingers).
         /// </summary>
         /// </summary>
@@ -210,11 +211,11 @@ namespace bbiwarg.Recognition.FingerRecognition
             Vector2D dirStart = direction.getOrthogonal(reversed);
             Vector2D dirStart = direction.getOrthogonal(reversed);
             Vector2D dirEnd = direction.getOrthogonal(!reversed);
             Vector2D dirEnd = direction.getOrthogonal(!reversed);
 
 
-            Vector2D startPositionStart = position + 0.5f*Parameters.FingerMinWidth2D * dirStart;
+            Vector2D startPositionStart = position + 0.5f * Parameters.FingerMinWidth2D * dirStart;
             Vector2D start = edgeImageAdapted.findNextRoughEdge(startPositionStart, dirStart, maxWidth2D);
             Vector2D start = edgeImageAdapted.findNextRoughEdge(startPositionStart, dirStart, maxWidth2D);
             if (start == null) return null;
             if (start == null) return null;
 
 
-            Vector2D endPositionStart = position + 0.5f*Parameters.FingerMinWidth2D * dirEnd;
+            Vector2D endPositionStart = position + 0.5f * Parameters.FingerMinWidth2D * dirEnd;
             Vector2D end = edgeImageAdapted.findNextRoughEdge(position, dirEnd, maxWidth2D);
             Vector2D end = edgeImageAdapted.findNextRoughEdge(position, dirEnd, maxWidth2D);
             if (end == null) return null;
             if (end == null) return null;
 
 

+ 1 - 1
bbiwarg/Recognition/FingerRecognition/FingerSliceTrail.cs

@@ -138,7 +138,7 @@ namespace bbiwarg.Recognition.FingerRecognition
         {
         {
             Slices.Reverse();
             Slices.Reverse();
 
 
-            if(lineSegmentUpToDate)
+            if (lineSegmentUpToDate)
                 lineSegment = new LineSegment2D(lineSegment.P2, lineSegment.P1);
                 lineSegment = new LineSegment2D(lineSegment.P2, lineSegment.P1);
 
 
             if (fittedDirectionUpToDate)
             if (fittedDirectionUpToDate)

+ 2 - 1
bbiwarg/Recognition/FingerRecognition/FingerTracker.cs

@@ -27,7 +27,8 @@ namespace bbiwarg.Recognition.FingerRecognition
         /// Updates the TrackedFingers with the detected fingers in the current frame and stores the tracked fingers.
         /// Updates the TrackedFingers with the detected fingers in the current frame and stores the tracked fingers.
         /// </summary>
         /// </summary>
         /// <param name="frameData">the current frame</param>
         /// <param name="frameData">the current frame</param>
-        public void trackFingers(FrameData frameData) {
+        public void trackFingers(FrameData frameData)
+        {
             trackObjects(frameData.DetectedFingers);
             trackObjects(frameData.DetectedFingers);
             frameData.TrackedFingers = getCurrentObjectsWithState(TrackingState.Tracked);
             frameData.TrackedFingers = getCurrentObjectsWithState(TrackingState.Tracked);
         }
         }

+ 1 - 1
bbiwarg/Recognition/HandRecognition/Hand.cs

@@ -98,7 +98,7 @@ namespace bbiwarg.Recognition.HandRecognition
                 {
                 {
                     Vector2D direction = slice.Direction;
                     Vector2D direction = slice.Direction;
                     Vector2D out1 = slice.Start.moveWithinBound(imageSize, direction.getInverse(), Parameters.FingerContourMargin);
                     Vector2D out1 = slice.Start.moveWithinBound(imageSize, direction.getInverse(), Parameters.FingerContourMargin);
-                    Vector2D out2 = slice.End.moveWithinBound(imageSize, direction, Parameters.FingerContourMargin); 
+                    Vector2D out2 = slice.End.moveWithinBound(imageSize, direction, Parameters.FingerContourMargin);
 
 
                     if (isInside(out1) && isInside(out2))
                     if (isInside(out1) && isInside(out2))
                     {
                     {

+ 9 - 6
bbiwarg/Recognition/HandRecognition/HandDetector.cs

@@ -84,12 +84,13 @@ namespace bbiwarg.Recognition.HandRecognition
         private void findHands()
         private void findHands()
         {
         {
             hands = new List<Hand>();
             hands = new List<Hand>();
-            otherHandsFingers = new Dictionary<Hand,List<Finger>>();
+            otherHandsFingers = new Dictionary<Hand, List<Finger>>();
             List<Finger> assignedFingers = new List<Finger>();
             List<Finger> assignedFingers = new List<Finger>();
 
 
             foreach (Finger finger in fingers)
             foreach (Finger finger in fingers)
             {
             {
-                if(!assignedFingers.Contains(finger)) {
+                if (!assignedFingers.Contains(finger))
+                {
                     Image<Gray, byte> handMask = getHandMask(finger.HandPoint);
                     Image<Gray, byte> handMask = getHandMask(finger.HandPoint);
 
 
                     int numPixels = handMask.CountNonzero()[0];
                     int numPixels = handMask.CountNonzero()[0];
@@ -102,14 +103,15 @@ namespace bbiwarg.Recognition.HandRecognition
                     List<Finger> fingersOnHand = new List<Finger>();
                     List<Finger> fingersOnHand = new List<Finger>();
                     List<Finger> fingersOnOtherHand = new List<Finger>();
                     List<Finger> fingersOnOtherHand = new List<Finger>();
 
 
-                    foreach (Finger f in fingers) {
+                    foreach (Finger f in fingers)
+                    {
                         if (!assignedFingers.Contains(f) && handMask.Data[f.HandPoint.IntY, f.HandPoint.IntX, 0] != 0)
                         if (!assignedFingers.Contains(f) && handMask.Data[f.HandPoint.IntY, f.HandPoint.IntX, 0] != 0)
                         {
                         {
                             fingersOnHand.Add(f);
                             fingersOnHand.Add(f);
                             assignedFingers.Add(f);
                             assignedFingers.Add(f);
                         }
                         }
                         else
                         else
-                            fingersOnOtherHand.Add(f);  
+                            fingersOnOtherHand.Add(f);
                     }
                     }
 
 
                     Hand hand = new Hand(handMask, fingersOnHand);
                     Hand hand = new Hand(handMask, fingersOnHand);
@@ -128,7 +130,7 @@ namespace bbiwarg.Recognition.HandRecognition
         {
         {
             Image<Gray, byte> mask = new Image<Gray, byte>(depthImage.Size.Width + 2, depthImage.Size.Height + 2);
             Image<Gray, byte> mask = new Image<Gray, byte>(depthImage.Size.Width + 2, depthImage.Size.Height + 2);
             MCvConnectedComp comp = new MCvConnectedComp();
             MCvConnectedComp comp = new MCvConnectedComp();
-            CvInvoke.cvFloodFill(modifiedHandDepthImage, p, new MCvScalar(255), new MCvScalar(Parameters.HandFloodFillDownDiff), 
+            CvInvoke.cvFloodFill(modifiedHandDepthImage, p, new MCvScalar(255), new MCvScalar(Parameters.HandFloodFillDownDiff),
                 new MCvScalar(Parameters.HandFloodFillUpDiff), out comp, Emgu.CV.CvEnum.CONNECTIVITY.FOUR_CONNECTED, Emgu.CV.CvEnum.FLOODFILL_FLAG.DEFAULT, mask);
                 new MCvScalar(Parameters.HandFloodFillUpDiff), out comp, Emgu.CV.CvEnum.CONNECTIVITY.FOUR_CONNECTED, Emgu.CV.CvEnum.FLOODFILL_FLAG.DEFAULT, mask);
             return mask.Copy(new Rectangle(1, 1, depthImage.Size.Width, depthImage.Size.Height));
             return mask.Copy(new Rectangle(1, 1, depthImage.Size.Width, depthImage.Size.Height));
         }
         }
@@ -250,7 +252,8 @@ namespace bbiwarg.Recognition.HandRecognition
         /// <summary>
         /// <summary>
         /// Finds the hands centroids.
         /// Finds the hands centroids.
         /// </summary>
         /// </summary>
-        private void findCentroids() {
+        private void findCentroids()
+        {
             foreach (Hand hand in hands)
             foreach (Hand hand in hands)
                 hand.findCentroid();
                 hand.findCentroid();
         }
         }

+ 1 - 1
bbiwarg/Recognition/TouchRecognition/TrackedTouch.cs

@@ -14,7 +14,7 @@ namespace bbiwarg.Recognition.TouchRecognition
     /// <param name="sender">the event sender</param>
     /// <param name="sender">the event sender</param>
     /// <param name="e">the touch event</param>
     /// <param name="e">the touch event</param>
     public delegate void TouchEventHandler(object sender, TouchEvent e);
     public delegate void TouchEventHandler(object sender, TouchEvent e);
-    
+
     /// <summary>
     /// <summary>
     /// Represents a touch that is tracked for several frames
     /// Represents a touch that is tracked for several frames
     /// </summary>
     /// </summary>

+ 4 - 3
bbiwarg/Recognition/Tracking/Similarity.cs

@@ -11,8 +11,8 @@ namespace bbiwarg.Recognition.Tracking
     /// </summary>
     /// </summary>
     /// <typeparam name="T">Type of the TrackableObject</typeparam>
     /// <typeparam name="T">Type of the TrackableObject</typeparam>
     /// <typeparam name="TrackedT">Type of the TrackedObject</typeparam>
     /// <typeparam name="TrackedT">Type of the TrackedObject</typeparam>
-    public class Similarity<T, TrackedT> 
-        where T :TrackableObject
+    public class Similarity<T, TrackedT>
+        where T : TrackableObject
         where TrackedT : TrackedObject<T>
         where TrackedT : TrackedObject<T>
     {
     {
         /// <summary>
         /// <summary>
@@ -37,7 +37,8 @@ namespace bbiwarg.Recognition.Tracking
         /// <param name="trackedObject">The tracked object.</param>
         /// <param name="trackedObject">The tracked object.</param>
         /// <param name="detectedObject">The detected object.</param>
         /// <param name="detectedObject">The detected object.</param>
         /// <param name="value">The value.</param>
         /// <param name="value">The value.</param>
-        public Similarity(TrackedT trackedObject, T detectedObject, float value) {
+        public Similarity(TrackedT trackedObject, T detectedObject, float value)
+        {
             TrackedObject = trackedObject;
             TrackedObject = trackedObject;
             DetectedObject = detectedObject;
             DetectedObject = detectedObject;
             Value = value;
             Value = value;

+ 2 - 1
bbiwarg/Recognition/Tracking/TrackIDPool.cs

@@ -19,7 +19,8 @@ namespace bbiwarg.Recognition.Tracking
         /// <summary>
         /// <summary>
         /// Initializes a new instance of the TrackIDPool class.
         /// Initializes a new instance of the TrackIDPool class.
         /// </summary>
         /// </summary>
-        public TrackIDPool() {
+        public TrackIDPool()
+        {
             usedIDs = new List<int>();
             usedIDs = new List<int>();
         }
         }
 
 

+ 1 - 1
bbiwarg/Recognition/Tracking/Tracker.cs

@@ -126,7 +126,7 @@ namespace bbiwarg.Recognition.Tracking
                     float similarityValue = calculateSimilarity(trackedObject, detectedObject);
                     float similarityValue = calculateSimilarity(trackedObject, detectedObject);
                     if (similarityValue > 0)
                     if (similarityValue > 0)
                         similarities.Add(new Similarity<T, TrackedT>(trackedObject, detectedObject, similarityValue));
                         similarities.Add(new Similarity<T, TrackedT>(trackedObject, detectedObject, similarityValue));
-                 }
+                }
             }
             }
 
 
             // sort depending on similarity-value
             // sort depending on similarity-value

+ 9 - 9
bbiwarg/TUIO/TuioCommunicator.cs

@@ -96,7 +96,7 @@ namespace bbiwarg.TUIO
                         List<TuioObject> palmTobjs = new List<TuioObject>();
                         List<TuioObject> palmTobjs = new List<TuioObject>();
                         Vector2D[] corners = palm.Quad.Corners;
                         Vector2D[] corners = palm.Quad.Corners;
                         for (int i = 0; i < 4; i++)
                         for (int i = 0; i < 4; i++)
-                            palmTobjs.Add(server.addTuioObject(corners[i].X, corners[i].Y, palm.TrackID + 0.1f*i));
+                            palmTobjs.Add(server.addTuioObject(corners[i].X, corners[i].Y, palm.TrackID + 0.1f * i));
                         tobjects.Add(palm.TrackID, palmTobjs);
                         tobjects.Add(palm.TrackID, palmTobjs);
                         updatedIDs.Add(palm.TrackID);
                         updatedIDs.Add(palm.TrackID);
                     }
                     }
@@ -104,16 +104,16 @@ namespace bbiwarg.TUIO
 
 
                 // remove
                 // remove
                 List<int> ids = tobjects.Keys.ToList();
                 List<int> ids = tobjects.Keys.ToList();
-                for (int i = ids.Count - 1; i >= 0;i-- )
+                for (int i = ids.Count - 1; i >= 0; i--)
+                {
+                    int id = ids[i];
+                    if (!updatedIDs.Contains(id))
                     {
                     {
-                        int id = ids[i];
-                        if (!updatedIDs.Contains(id))
-                        {
-                            foreach (TuioObject tobj in tobjects[id])
-                                server.removeTuioObject(tobj);
-                            tobjects.Remove(id);
-                        }
+                        foreach (TuioObject tobj in tobjects[id])
+                            server.removeTuioObject(tobj);
+                        tobjects.Remove(id);
                     }
                     }
+                }
             }
             }
             server.commitFrame();
             server.commitFrame();
         }
         }

+ 10 - 6
bbiwarg/Utility/ConvexityDefect.cs

@@ -17,12 +17,12 @@ namespace bbiwarg.Utility
         /// the point of start and end point which is nearer to the depth point
         /// the point of start and end point which is nearer to the depth point
         /// </summary>
         /// </summary>
         public Vector2D OuterShort { get; private set; }
         public Vector2D OuterShort { get; private set; }
-        
+
         /// <summary>
         /// <summary>
         /// the point of start and end point which is farther away from the depth point
         /// the point of start and end point which is farther away from the depth point
         /// </summary>
         /// </summary>
         public Vector2D OuterLong { get; private set; }
         public Vector2D OuterLong { get; private set; }
-        
+
         /// <summary>
         /// <summary>
         /// the depth point
         /// the depth point
         /// </summary>
         /// </summary>
@@ -53,7 +53,8 @@ namespace bbiwarg.Utility
         /// Constructs a ConvexityDefect.
         /// Constructs a ConvexityDefect.
         /// </summary>
         /// </summary>
         /// <param name="mcvConvexityDefect">the emgu convexity defect which has start, end and depth point</param>
         /// <param name="mcvConvexityDefect">the emgu convexity defect which has start, end and depth point</param>
-        public ConvexityDefect(MCvConvexityDefect mcvConvexityDefect) {
+        public ConvexityDefect(MCvConvexityDefect mcvConvexityDefect)
+        {
             Inner = new Vector2D(mcvConvexityDefect.DepthPoint);
             Inner = new Vector2D(mcvConvexityDefect.DepthPoint);
             Vector2D p1 = new Vector2D(mcvConvexityDefect.StartPoint);
             Vector2D p1 = new Vector2D(mcvConvexityDefect.StartPoint);
             Vector2D p2 = new Vector2D(mcvConvexityDefect.EndPoint);
             Vector2D p2 = new Vector2D(mcvConvexityDefect.EndPoint);
@@ -63,7 +64,8 @@ namespace bbiwarg.Utility
                 OuterLong = p1;
                 OuterLong = p1;
                 OuterShort = p2;
                 OuterShort = p2;
             }
             }
-            else {
+            else
+            {
                 OuterLong = p2;
                 OuterLong = p2;
                 OuterShort = p1;
                 OuterShort = p1;
             }
             }
@@ -79,7 +81,8 @@ namespace bbiwarg.Utility
         /// </summary>
         /// </summary>
         /// <param name="thumb">finger representing the thumb</param>
         /// <param name="thumb">finger representing the thumb</param>
         /// <returns>true iff this defect is a possible thumb defect</returns>
         /// <returns>true iff this defect is a possible thumb defect</returns>
-        public bool isPossibleThumbDefect(Finger thumb) {
+        public bool isPossibleThumbDefect(Finger thumb)
+        {
             float tipDistance = thumb.TipPoint.getDistanceTo(OuterShort);
             float tipDistance = thumb.TipPoint.getDistanceTo(OuterShort);
             float handDistance = thumb.HandPoint.getDistanceTo(Inner);
             float handDistance = thumb.HandPoint.getDistanceTo(Inner);
             float thumbShortLengthRatio = thumb.LineSegment.Length / VectorShort.Length;
             float thumbShortLengthRatio = thumb.LineSegment.Length / VectorShort.Length;
@@ -96,7 +99,8 @@ namespace bbiwarg.Utility
         /// </summary>
         /// </summary>
         /// <param name="finger">the finger maybe causing the defect</param>
         /// <param name="finger">the finger maybe causing the defect</param>
         /// <returns>true iff this defect is caused by finger</returns>
         /// <returns>true iff this defect is caused by finger</returns>
-        public bool isCausedByFinger(Finger finger) {
+        public bool isCausedByFinger(Finger finger)
+        {
             return (OuterLineSegment.intersectsWith(finger.LineSegment));
             return (OuterLineSegment.intersectsWith(finger.LineSegment));
         }
         }
     }
     }

+ 5 - 3
bbiwarg/Utility/CoordinateConverter.cs

@@ -59,7 +59,8 @@ namespace bbiwarg.Utility
         /// <param name="p">the point</param>
         /// <param name="p">the point</param>
         /// <param name="depth">the depth</param>
         /// <param name="depth">the depth</param>
         /// <returns>the 3d position</returns>
         /// <returns>the 3d position</returns>
-        public Vector3D convertCoordinate2Dto3D(Vector2D p, float depth) {
+        public Vector3D convertCoordinate2Dto3D(Vector2D p, float depth)
+        {
             return convertCoordinate2Dto3D(p.X, p.Y, depth);
             return convertCoordinate2Dto3D(p.X, p.Y, depth);
         }
         }
 
 
@@ -81,7 +82,7 @@ namespace bbiwarg.Utility
             float a = depth * depth;
             float a = depth * depth;
             float b = (float)(Math.Pow(tanX, 2) + Math.Pow(tanY, 2));
             float b = (float)(Math.Pow(tanX, 2) + Math.Pow(tanY, 2));
 
 
-            float z3 = (float)(Math.Sqrt(0.5f*a + Math.Sqrt(0.25f*Math.Pow(a,2)-b)));
+            float z3 = (float)(Math.Sqrt(0.5f * a + Math.Sqrt(0.25f * Math.Pow(a, 2) - b)));
             float x3 = tanX * z3;
             float x3 = tanX * z3;
             float y3 = tanY * z3;
             float y3 = tanY * z3;
 
 
@@ -94,7 +95,8 @@ namespace bbiwarg.Utility
         /// <param name="length">3d length of the linesegment</param>
         /// <param name="length">3d length of the linesegment</param>
         /// <param name="depth">depth of the linesegment</param>
         /// <param name="depth">depth of the linesegment</param>
         /// <returns>2d length of the linesegment</returns>
         /// <returns>2d length of the linesegment</returns>
-        public float convertLength3Dto2D(float length, float depth) {
+        public float convertLength3Dto2D(float length, float depth)
+        {
             float fullLengthX = (float)(2 * Math.Cos(hfov / 2) * depth);
             float fullLengthX = (float)(2 * Math.Cos(hfov / 2) * depth);
             float fullLengthY = (float)(2 * Math.Cos(vfov / 2) * depth);
             float fullLengthY = (float)(2 * Math.Cos(vfov / 2) * depth);
             float fullLengthDiagonal = (float)Math.Sqrt(Math.Pow(fullLengthX, 2) + Math.Pow(fullLengthY, 2));
             float fullLengthDiagonal = (float)Math.Sqrt(Math.Pow(fullLengthX, 2) + Math.Pow(fullLengthY, 2));

+ 9 - 6
bbiwarg/Utility/ImageSize.cs

@@ -15,17 +15,17 @@ namespace bbiwarg.Utility
         /// <summary>
         /// <summary>
         /// image width
         /// image width
         /// </summary>
         /// </summary>
-        public int Width {get; private set;}
+        public int Width { get; private set; }
 
 
         /// <summary>
         /// <summary>
         /// image height
         /// image height
         /// </summary>
         /// </summary>
-        public int Height {get; private set;}
+        public int Height { get; private set; }
 
 
         /// <summary>
         /// <summary>
         /// position in the image with maximum x and y values
         /// position in the image with maximum x and y values
         /// </summary>
         /// </summary>
-        public Vector2D MaxPixel {get; private set;}
+        public Vector2D MaxPixel { get; private set; }
 
 
         /// <summary>
         /// <summary>
         /// the length of the longer image diagonal
         /// the length of the longer image diagonal
@@ -43,7 +43,8 @@ namespace bbiwarg.Utility
         /// </summary>
         /// </summary>
         /// <param name="width">image width</param>
         /// <param name="width">image width</param>
         /// <param name="height">image height</param>
         /// <param name="height">image height</param>
-        public ImageSize(int width, int height) {
+        public ImageSize(int width, int height)
+        {
             Width = width;
             Width = width;
             Height = height;
             Height = height;
             MaxPixel = new Vector2D(width - 1, height - 1);
             MaxPixel = new Vector2D(width - 1, height - 1);
@@ -54,7 +55,8 @@ namespace bbiwarg.Utility
         /// </summary>
         /// </summary>
         /// <param name="relativePoint">realtive point (x and y in [0,1])</param>
         /// <param name="relativePoint">realtive point (x and y in [0,1])</param>
         /// <returns>absolute point</returns>
         /// <returns>absolute point</returns>
-        public Vector2D getAbsolutePoint(Vector2D relativePoint) {
+        public Vector2D getAbsolutePoint(Vector2D relativePoint)
+        {
             return relativePoint.scale(MaxPixel);
             return relativePoint.scale(MaxPixel);
         }
         }
 
 
@@ -63,7 +65,8 @@ namespace bbiwarg.Utility
         /// </summary>
         /// </summary>
         /// <param name="absolutePoint">absolute point in the image</param>
         /// <param name="absolutePoint">absolute point in the image</param>
         /// <returns>realtive point (x and y in [0,1])</returns>
         /// <returns>realtive point (x and y in [0,1])</returns>
-        public Vector2D getRelativePoint(Vector2D absolutePoint) {
+        public Vector2D getRelativePoint(Vector2D absolutePoint)
+        {
             return new Vector2D(absolutePoint.X / Width, absolutePoint.Y / Height);
             return new Vector2D(absolutePoint.X / Width, absolutePoint.Y / Height);
         }
         }
     }
     }

+ 3 - 3
bbiwarg/Utility/Kalman2DPositionFilter.cs

@@ -33,12 +33,12 @@ namespace bbiwarg.Utility
         /// yy entry for the measurement noise covariance matrix
         /// yy entry for the measurement noise covariance matrix
         /// </summary> 
         /// </summary> 
         private float mYY;
         private float mYY;
-        
+
         /// <summary>
         /// <summary>
         /// value used for all entries in the process noise covariance matrix
         /// value used for all entries in the process noise covariance matrix
         /// </summary>
         /// </summary>
         private float processNoiseFactor;
         private float processNoiseFactor;
-        
+
 
 
         /// <summary>
         /// <summary>
         /// number of measurements per second
         /// number of measurements per second
@@ -130,7 +130,7 @@ namespace bbiwarg.Utility
         public void setInitialPosition(Vector2D initialPosition)
         public void setInitialPosition(Vector2D initialPosition)
         {
         {
             // initial state (x, y, v_x, v_y)
             // initial state (x, y, v_x, v_y)
-            Matrix<float> initialState = new Matrix<float>(new float[] { initialPosition.X, initialPosition.Y});
+            Matrix<float> initialState = new Matrix<float>(new float[] { initialPosition.X, initialPosition.Y });
             kalman.CorrectedState = initialState;
             kalman.CorrectedState = initialState;
 
 
             Initialized = true;
             Initialized = true;

+ 2 - 2
bbiwarg/Utility/Line2D.cs

@@ -25,7 +25,7 @@ namespace bbiwarg.Utility
         /// one point on the line
         /// one point on the line
         /// </summary>
         /// </summary>
         public Vector2D PointOnLine { get; private set; }
         public Vector2D PointOnLine { get; private set; }
-        
+
         /// <summary>
         /// <summary>
         /// direction vector of the line
         /// direction vector of the line
         /// </summary>
         /// </summary>
@@ -88,7 +88,7 @@ namespace bbiwarg.Utility
 
 
             return new Vector2D(newX, newY);
             return new Vector2D(newX, newY);
         }
         }
-        
+
         /// <summary>
         /// <summary>
         /// Computes the intersection of two lines, iff the lines do not intersect it returns null.
         /// Computes the intersection of two lines, iff the lines do not intersect it returns null.
         /// </summary>
         /// </summary>

+ 2 - 1
bbiwarg/Utility/LineSegment2D.cs

@@ -56,7 +56,8 @@ namespace bbiwarg.Utility
         /// </summary>
         /// </summary>
         /// <param name="ls">second LineSegment</param>
         /// <param name="ls">second LineSegment</param>
         /// <returns>Intersection iff its defined, else null</returns>
         /// <returns>Intersection iff its defined, else null</returns>
-        public bool intersectsWith(LineSegment2D ls) {
+        public bool intersectsWith(LineSegment2D ls)
+        {
             Vector2D intersection = Line.getIntersection(ls.Line);
             Vector2D intersection = Line.getIntersection(ls.Line);
             return (intersection != null && intersection.isInBox(P1, P2) && intersection.isInBox(ls.P1, ls.P2));
             return (intersection != null && intersection.isInBox(P1, P2) && intersection.isInBox(ls.P1, ls.P2));
         }
         }

+ 14 - 8
bbiwarg/Utility/Projection2DTo2D.cs

@@ -57,7 +57,8 @@ namespace bbiwarg.Utility
         /// <param name="sizeA">size of the image the original points are in</param>
         /// <param name="sizeA">size of the image the original points are in</param>
         /// <param name="sizeB">size of the image the projected points are in</param>
         /// <param name="sizeB">size of the image the projected points are in</param>
         /// <param name="numPointsForCalibration">number of points used for the calibration</param>
         /// <param name="numPointsForCalibration">number of points used for the calibration</param>
-        public Projection2DTo2D(ImageSize sizeA, ImageSize sizeB, int numPointsForCalibration = 4) {
+        public Projection2DTo2D(ImageSize sizeA, ImageSize sizeB, int numPointsForCalibration = 4)
+        {
             this.sizeA = sizeA;
             this.sizeA = sizeA;
             this.sizeB = sizeB;
             this.sizeB = sizeB;
             this.numPointsForCalibration = numPointsForCalibration;
             this.numPointsForCalibration = numPointsForCalibration;
@@ -68,7 +69,8 @@ namespace bbiwarg.Utility
         /// <summary>
         /// <summary>
         /// Resets the calibration.
         /// Resets the calibration.
         /// </summary>
         /// </summary>
-        public void reset() {
+        public void reset()
+        {
             homography = null;
             homography = null;
             IsCalibrated = false;
             IsCalibrated = false;
             calibrationPointsA = new List<PointF>();
             calibrationPointsA = new List<PointF>();
@@ -80,7 +82,8 @@ namespace bbiwarg.Utility
         /// </summary>
         /// </summary>
         /// <param name="pointA">point in the first image</param>
         /// <param name="pointA">point in the first image</param>
         /// <param name="pointB">point in the second image</param>
         /// <param name="pointB">point in the second image</param>
-        public void addCalibrationPoints(Vector2D pointA, Vector2D pointB) {
+        public void addCalibrationPoints(Vector2D pointA, Vector2D pointB)
+        {
             calibrationPointsA.Add(sizeA.getRelativePoint(pointA));
             calibrationPointsA.Add(sizeA.getRelativePoint(pointA));
             calibrationPointsB.Add(sizeB.getRelativePoint(pointB));
             calibrationPointsB.Add(sizeB.getRelativePoint(pointB));
 
 
@@ -93,8 +96,9 @@ namespace bbiwarg.Utility
         /// </summary>
         /// </summary>
         /// <param name="pointA">the point to project</param>
         /// <param name="pointA">the point to project</param>
         /// <returns>projected point</returns>
         /// <returns>projected point</returns>
-        public Vector2D projectPoint(Vector2D pointA) {
-            PointF[] pointfsB = new PointF[1] {sizeA.getRelativePoint(pointA)};
+        public Vector2D projectPoint(Vector2D pointA)
+        {
+            PointF[] pointfsB = new PointF[1] { sizeA.getRelativePoint(pointA) };
             homography.ProjectPoints(pointfsB);
             homography.ProjectPoints(pointfsB);
             return sizeB.getAbsolutePoint(new Vector2D(pointfsB[0]));
             return sizeB.getAbsolutePoint(new Vector2D(pointfsB[0]));
         }
         }
@@ -102,9 +106,10 @@ namespace bbiwarg.Utility
         /// <summary>
         /// <summary>
         /// Computes the homography from the lists of calibration points.
         /// Computes the homography from the lists of calibration points.
         /// </summary>
         /// </summary>
-        private void calibrate() {
+        private void calibrate()
+        {
             homography = CameraCalibration.FindHomography(calibrationPointsA.ToArray(), calibrationPointsB.ToArray(), Emgu.CV.CvEnum.HOMOGRAPHY_METHOD.DEFAULT, 0.995);
             homography = CameraCalibration.FindHomography(calibrationPointsA.ToArray(), calibrationPointsB.ToArray(), Emgu.CV.CvEnum.HOMOGRAPHY_METHOD.DEFAULT, 0.995);
-            
+
             calibrationPointsA.Clear();
             calibrationPointsA.Clear();
             calibrationPointsB.Clear();
             calibrationPointsB.Clear();
             IsCalibrated = true;
             IsCalibrated = true;
@@ -115,7 +120,8 @@ namespace bbiwarg.Utility
         /// <summary>
         /// <summary>
         /// Writes the homography to a file.
         /// Writes the homography to a file.
         /// </summary>
         /// </summary>
-        private void exportHomography() {
+        private void exportHomography()
+        {
             String[] fileData = new String[homography.Size.Height];
             String[] fileData = new String[homography.Size.Height];
             StringBuilder sb = new StringBuilder();
             StringBuilder sb = new StringBuilder();
             for (int r = 0; r < homography.Size.Height; r++)
             for (int r = 0; r < homography.Size.Height; r++)

+ 1 - 1
bbiwarg/Utility/Quadrangle.cs

@@ -95,7 +95,7 @@ namespace bbiwarg.Utility
         /// <param name="point">the point</param>
         /// <param name="point">the point</param>
         /// <param name="tolerance">the tolerance value</param>
         /// <param name="tolerance">the tolerance value</param>
         /// <returns>true iff the point is inside the quadrangle(plus tolerance)</returns>
         /// <returns>true iff the point is inside the quadrangle(plus tolerance)</returns>
-        public bool isInside(Vector2D point, float tolerance=0.0f)
+        public bool isInside(Vector2D point, float tolerance = 0.0f)
         {
         {
             Vector2D relativePos = getRelativePosition(point);
             Vector2D relativePos = getRelativePosition(point);
             float min = 0 - tolerance;
             float min = 0 - tolerance;

+ 3 - 3
bbiwarg/Utility/Vector2D.cs

@@ -17,7 +17,7 @@ namespace bbiwarg.Utility
         /// length of the vector, is initialized with -1 and will only be calculated if needed and only once
         /// length of the vector, is initialized with -1 and will only be calculated if needed and only once
         /// </summary>
         /// </summary>
         private float length = -1;
         private float length = -1;
-        
+
         /// <summary>
         /// <summary>
         /// the null vector or origin
         /// the null vector or origin
         /// </summary>
         /// </summary>
@@ -174,7 +174,7 @@ namespace bbiwarg.Utility
         {
         {
             return (X >= topLeft.X && X <= bottomRight.X && Y >= topLeft.Y && Y <= bottomRight.Y);
             return (X >= topLeft.X && X <= bottomRight.X && Y >= topLeft.Y && Y <= bottomRight.Y);
         }
         }
-        
+
         /// <summary>
         /// <summary>
         /// Moves this vector along the direction vector factor times inside the imageSize, this point won't leave the image.
         /// Moves this vector along the direction vector factor times inside the imageSize, this point won't leave the image.
         /// </summary>
         /// </summary>
@@ -195,7 +195,7 @@ namespace bbiwarg.Utility
             }
             }
             return newPosition;
             return newPosition;
         }
         }
-        
+
         /// <summary>
         /// <summary>
         /// Normalizes this vector with the euclidean norm (2. norm).
         /// Normalizes this vector with the euclidean norm (2. norm).
         /// </summary>
         /// </summary>