Browse Source

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

Alexander Hendrich 10 years ago
parent
commit
06006a8ee5

+ 6 - 5
bbiwarg/Constants.cs

@@ -5,20 +5,21 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
+using bbiwarg.Utility;
+
 namespace bbiwarg
 {
     class Constants
     {
+        // Logger
+        public static readonly Logger.LogSubject LogLevel =
+            Logger.LogSubject.FingerTracker;
+        
         // BBIWARG
         public static readonly int OutputNumImages = 5;
         public static readonly int OutputNumImagesPerRow = 3;
         public static readonly float OutputScaleFactor = 1f; // output window size is scaled by this factor (from necessary size for images)
 
-        // debug
-        public static readonly bool OutputTimerEnabled = false;
-        public static readonly bool VerboseTUIO = false;
-        public static readonly bool VerboseFingerTracker = true;
-
         // confidence image
         public static readonly int ConfidenceImageMinThreshold = 500;
 

+ 1 - 2
bbiwarg/Graphics/OutputWindow.cs

@@ -165,8 +165,7 @@ namespace bbiwarg.Graphics
 
             Timer.stop("onRenderFrame");
             
-            if(Constants.OutputTimerEnabled)
-                Timer.outputAll();
+            Timer.outputAll();
         }
 
     }

+ 0 - 1
bbiwarg/InputProvider/IisuInputProvider.cs

@@ -121,7 +121,6 @@ namespace bbiwarg.InputProviders
             return active;
         }
 
-
         // Data-methodes
         public InputFrame getInputFrame() {
             //depthData

+ 7 - 4
bbiwarg/Recognition/FingerRecognition/FingerTracker.cs

@@ -7,6 +7,8 @@ using System.Threading.Tasks;
 using bbiwarg.Images;
 using bbiwarg.Graphics;
 
+using bbiwarg.Utility;
+
 namespace bbiwarg.Recognition.FingerRecognition
 {
     struct FingerSimilarity
@@ -42,7 +44,7 @@ namespace bbiwarg.Recognition.FingerRecognition
                 {
                     FingerHistory fh = new FingerHistory(finger);
                     FingerHistories.Add(fh);
-                    if (Constants.VerboseFingerTracker) Console.WriteLine("Finger #" + fh.ID + " detected");
+                    Logger.log("Finger #" + fh.ID + " detected", Logger.LogSubject.FingerTracker);
                 }
             }
             else
@@ -87,13 +89,14 @@ namespace bbiwarg.Recognition.FingerRecognition
             {
                 FingerHistory fh = new FingerHistory(finger);
                 FingerHistories.Add(fh);
-                if (Constants.VerboseFingerTracker) Console.WriteLine("Finger #" + fh.ID + " detected");
+                Logger.log("Finger #" + fh.ID + " detected", Logger.LogSubject.FingerTracker);
             }
 
             //add null finger to TrackedFingers that haven't found a match in this frame (status tracked->lost)
             foreach (FingerHistory fh in unasignedFingerHistories)
             {
-                if (Constants.VerboseFingerTracker && fh.CurrentState != TrackingState.Lost) Console.WriteLine("Finger #" + fh.ID + " lost");
+                if (fh.CurrentState != TrackingState.Lost) 
+                    Logger.log("Finger #" + fh.ID + " lost", Logger.LogSubject.FingerTracker);
                 fh.addFinger(null);
             }
 
@@ -149,7 +152,7 @@ namespace bbiwarg.Recognition.FingerRecognition
                 if (fh.CurrentState == TrackingState.Lost && fh.getNumFramesInCurrentState() >= Constants.FingerNumFramesUntilLost)
                 {
                     FingerHistories.RemoveAt(i);
-                    if (Constants.VerboseFingerTracker) Console.WriteLine("Finger #" + fh.ID + " deleted");
+                    Logger.log("Finger #" + fh.ID + " deleted", Logger.LogSubject.FingerTracker);
                 }
             }
         }

+ 4 - 2
bbiwarg/Server/TUIO/TuioServer.cs

@@ -7,6 +7,8 @@ using System.Threading.Tasks;
 using OSC.NET;
 //using System.Runtime.InteropServices;
 
+using bbiwarg.Utility;
+
 namespace TUIO
 {
     class TuioServer
@@ -132,8 +134,8 @@ namespace TUIO
                 }*/
                 packet.Append(currentMessage);
 
-                if(bbiwarg.Constants.VerboseTUIO)
-                    Console.WriteLine("Send Cursor "+cursor.getSessionID()+" at time "+TuioTime.getSystemTime().ToString());
+                Logger.log("Send Cursor "+cursor.getSessionID()+" at time "+TuioTime.getSystemTime().ToString(), Logger.LogSubject.TUIOServer);
+
             }
             currentMessage = new OSCMessage("/tuio/2Dcur");
             currentMessage.Append("fseq");

+ 29 - 0
bbiwarg/Utility/Logger.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace bbiwarg.Utility
+{
+    static class Logger
+    {
+        public enum LogSubject
+        {
+            FingerDetector = 1,
+            FingerTracker = 2,
+            HandDetector = 4,
+            PalmDetector = 8,
+            TouchDetector = 16,
+            TouchTracker = 32,
+            TUIOServer = 64,
+            Timer = 128
+        }
+
+        public static void log(string message, LogSubject subject)
+        {
+            if (Constants.LogLevel.HasFlag(subject))
+                Console.WriteLine(message);
+        }
+    }
+}

+ 5 - 4
bbiwarg/Utility/Timer.cs

@@ -37,15 +37,16 @@ namespace bbiwarg.Utility
         }
 
         public static void output(String name) {
-            Console.WriteLine("name:{0}\tavg:{1:00.00}\tmin:{2:00.00}\tmax:{3:00.00}", name, sumTimes[name] / Math.Max(numTimes[name], 1), minTimes[name], maxTimes[name]);
-       }
+            Logger.log(String.Format("name:{0}\tavg:{1:00.00}\tmin:{2:00.00}\tmax:{3:00.00}",
+                name, sumTimes[name] / Math.Max(numTimes[name], 1), minTimes[name], maxTimes[name]), Logger.LogSubject.Timer);
+        }
 
         public static void outputAll() {
-            Console.WriteLine("---TIMERS-START---");
+            Logger.log("---TIMERS-START---", Logger.LogSubject.Timer);
             foreach (String name in stopwatches.Keys) {
                 output(name);
             }
-            Console.WriteLine("---TIMERS-END---");
+            Logger.log("---TIMERS-END---", Logger.LogSubject.Timer);
         }
 
     }

+ 1 - 0
bbiwarg/bbiwarg.csproj

@@ -104,6 +104,7 @@
     <Compile Include="Utility\Kalman2DPositionFilter.cs" />
     <Compile Include="Utility\Line2D.cs" />
     <Compile Include="Utility\LineSegment2D.cs" />
+    <Compile Include="Utility\Logger.cs" />
     <Compile Include="Utility\Quadrangle.cs" />
     <Compile Include="Utility\Timer.cs" />
     <Compile Include="Utility\Vector2D.cs" />