Browse Source

perfomance improvements

Alexander Hendrich 11 years ago
parent
commit
97097b5044

+ 6 - 3
bbiwarg/Graphics/OutputImage.cs

@@ -68,9 +68,12 @@ namespace bbiwarg.Graphics
 
         public void drawImage(Image<Gray, byte> image, Color color)
         {
-            Image[0] = Image[0].Or(image.Mul((float)color.R / byte.MaxValue));
-            Image[1] = Image[1].Or(image.Mul((float)color.G / byte.MaxValue));
-            Image[2] = Image[2].Or(image.Mul((float)color.B / byte.MaxValue));
+            if(color.R != 0)
+                Image[0] = image.Mul((float)color.R / byte.MaxValue);
+            if(color.G != 0)
+                Image[1] = image.Mul((float)color.G / byte.MaxValue);
+            if(color.B != 0)
+                Image[2] = image.Mul((float)color.B / byte.MaxValue);
         }
 
         public void drawQuadrangleGrid(Quadrangle quad, Color borderColor, Color gridColor, int numRows, int numCols) {

+ 3 - 3
bbiwarg/Images/EdgeImage.cs

@@ -29,10 +29,10 @@ namespace bbiwarg.Images
             RoughImage = Image.Dilate(Constants.EdgeImageRoughNumDilationIterations);
         }
 
-        public EdgeImage(Image<Gray, Byte> edgeImage)
+        public EdgeImage(Image<Gray, Byte> edgeImage, Image<Gray, Byte> roughEdgeImage)
         {
             Image = edgeImage;
-            RoughImage = Image.Dilate(Constants.EdgeImageRoughNumDilationIterations);
+            RoughImage = roughEdgeImage;
         }
 
         public bool isEdgeAt(Point point)
@@ -107,7 +107,7 @@ namespace bbiwarg.Images
 
         public EdgeImage copy()
         {
-            return new EdgeImage(Image.Copy());
+            return new EdgeImage(Image.Copy(), RoughImage.Copy());
         }
     }
 }

+ 10 - 0
bbiwarg/InputHandler.cs

@@ -125,7 +125,11 @@ namespace bbiwarg
 
         private void beforeUpdateFrame()
         {
+            Timer.start("beforeUpdateFrame");
+
+            Timer.start("getInputFrame");
             currentInputFrame = inputProvider.getInputFrame();
+            Timer.stop("getInputFrame");
 
             lastFrame = currentFrame;
             currentFrame = currentInputFrame.FrameNumber;
@@ -133,15 +137,21 @@ namespace bbiwarg
 
             if (Constants.TuioEnabled)
                 tuioCommunicator.initFrame();
+
+            Timer.stop("beforeUpdateFrame");
         }
 
         private void afterUpdateFrame()
         {
+            Timer.start("afterUpdateFrame");
+
             if (Constants.TuioEnabled)
                 tuioCommunicator.commitFrame();
 
             if (Constants.OutputEnabled)
                 createOutputImages();
+
+            Timer.stop("afterUpdateFrame");
         }
 
         private void createConfidenceImage()

+ 1 - 1
bbiwarg/InputProviders/InputProvider.cs

@@ -59,7 +59,7 @@ namespace bbiwarg.InputProviders
 
         public InputFrame getInputFrame()
         {
-            device.UpdateFrame(true);
+            device.UpdateFrame(false);
             frameCounter++;
             IntPtr rawDepthData = depthImage.Value.Raw;
             IntPtr rawConfidenceData = confidenceImage.Value.Raw;