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

added nonvisual output
reworked timer output

Alexander Hendrich пре 10 година
родитељ
комит
ca573c0b8f
4 измењених фајлова са 18 додато и 8 уклоњено
  1. 1 1
      bbiwarg/Constants.cs
  2. 4 4
      bbiwarg/InputHandler.cs
  3. 8 1
      bbiwarg/MainBBWIWARG.cs
  4. 5 2
      bbiwarg/Utility/Timer.cs

+ 1 - 1
bbiwarg/Constants.cs

@@ -12,7 +12,7 @@ namespace bbiwarg
     class Constants
     {
         // Logger
-        public static readonly LogSubject LogLevel = LogSubject.TouchEvents;
+        public static readonly LogSubject LogLevel = LogSubject.Timer;
         public static readonly int ConsoleWidth = 90;
         public static readonly int ConsoleHeight = 30;
         

+ 4 - 4
bbiwarg/InputHandler.cs

@@ -146,10 +146,10 @@ namespace bbiwarg
 
         private void createConfidenceImage()
         {
-            Timer.start("createConfidenceImage");
+            Timer.start("createCnfdncImg");
             Image<Gray, Int16> rawConfidenceImage = new Image<Gray, Int16>(imageWidth, imageHeight, imageWidth * 2, currentInputFrame.RawConfidenceData);
             confidenceImage = new ConfidenceImage(rawConfidenceImage);
-            Timer.stop("createConfidenceImage");
+            Timer.stop("createCnfdncImg");
         }
 
         private void createDepthImage()
@@ -191,9 +191,9 @@ namespace bbiwarg
 
         private void detectPalm()
         {
-            Timer.start("detectPalm");
+            Timer.start("detectPalmQuad");
             palmDetector.findPalmQuad(handDetector.Hands, handDetector.HandMask);
-            Timer.stop("detectPalm");
+            Timer.stop("detectPalmQuad");
         }
 
         private void detectTouchEvents()

+ 8 - 1
bbiwarg/MainBBWIWARG.cs

@@ -1,5 +1,7 @@
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
+using System.Threading;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -29,7 +31,12 @@ namespace bbiwarg
                 outputWindow.Run(Constants.OutputFrameRate);
             }
             else
-                throw new NotImplementedException("non-video mode not supported yet");
+            {
+                while (true) {
+                    inputHandler.updateFrame();
+                    Thread.Sleep(1000 / Constants.OutputFrameRate);
+                }
+            }
 
             inputProvider.stop();
         }

+ 5 - 2
bbiwarg/Utility/Timer.cs

@@ -10,6 +10,7 @@ namespace bbiwarg.Utility
     class Timer
     {
         private static Dictionary<String, Stopwatch> stopwatches = new Dictionary<string, Stopwatch>();
+        private static Dictionary<String, double> currentTimes = new Dictionary<string, double>();
         private static Dictionary<String, double> minTimes = new Dictionary<string, double>();
         private static Dictionary<String, double> maxTimes = new Dictionary<string, double>();
         private static Dictionary<String, double> sumTimes = new Dictionary<string, double>();
@@ -23,6 +24,7 @@ namespace bbiwarg.Utility
                 maxTimes.Add(name, 0);
                 sumTimes.Add(name, 0);
                 numTimes.Add(name, 0);
+                currentTimes.Add(name, 0);
             }
             stopwatches[name].Restart();
         }
@@ -34,11 +36,12 @@ namespace bbiwarg.Utility
             if (time > maxTimes[name]) maxTimes[name] = time;
             sumTimes[name] += time;
             numTimes[name]++;
+            currentTimes[name] = time;
         }
 
         public static void output(String 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]), LogSubject.Timer);
+            Logger.log(String.Format("name:{0}\tavg:{1:00.00}\tcurrent:{2:00.00}",
+                name, sumTimes[name] / Math.Max(numTimes[name], 1), currentTimes[name]), LogSubject.Timer);
         }
 
         public static void outputAll()