Browse Source

fixed crash when closing GameWindow

Alexander Hendrich 11 years ago
parent
commit
46dfe83dc8
3 changed files with 16 additions and 2 deletions
  1. 7 1
      bbiwarg/DepthImage.cs
  2. 3 0
      bbiwarg/MainBBWIWARG.cs
  3. 6 1
      bbiwarg/VideoHandle.cs

+ 7 - 1
bbiwarg/DepthImage.cs

@@ -27,6 +27,9 @@ namespace bbiwarg
             this.height = height;
             this.image = image;
 
+            Stopwatch sw = new Stopwatch();
+            sw.Start();
+
             this.image = this.image.SmoothMedian(3);
             //minDepth
             findMinDepth();
@@ -44,6 +47,9 @@ namespace bbiwarg
             //findFingers
             findFingers();
 
+            sw.Stop();
+            Console.WriteLine(sw.ElapsedMilliseconds);
+
         }
 
         public int getWidth() {
@@ -109,7 +115,7 @@ namespace bbiwarg
 
         private void calculateEdges() {
             Image<Gray, Byte> tmp = image.Convert<Byte>(delegate(Int16 depth) { return (byte)(((depth - minDepth) * Byte.MaxValue) / (maxDepth - minDepth)); });
-            Image<Gray, byte> tmp2 = tmp.Canny(150, 75, 3);
+            Image<Gray, byte> tmp2 = tmp.Canny(100, 75, 3);
             edges = tmp2.Convert<Int16>(delegate(byte depth) { if(depth > 0) {return Int16.MaxValue;} else {return 0;}});//((depth * Int16.MaxValue) / Byte.MaxValue); });
         }
 

+ 3 - 0
bbiwarg/MainBBWIWARG.cs

@@ -14,9 +14,12 @@ namespace bbiwarg
         {
             IInputProvider inputProvider = new IisuInputProvider("..\\..\\videos\\touch\\3.skv");
             VideoHandle videoHandle = new VideoHandle(inputProvider);
+            videoHandle.start();
 
             OutputWindow output = new OutputWindow(videoHandle);
             output.Run(30);
+
+            videoHandle.stop();
         }
     }
 }

+ 6 - 1
bbiwarg/VideoHandle.cs

@@ -15,13 +15,18 @@ namespace bbiwarg
 
         public VideoHandle(IInputProvider inputProvider) {
             this.inputProvider = inputProvider;
+        }
 
+        public void start() {
             inputProvider.init();
             inputProvider.start();
             inputProvider.updateFrame();
             inputFrame = inputProvider.getInputFrame();
             depthImage = inputFrame.getDepthImage();
-
+        }
+       
+        public void stop() {
+            inputProvider.stop();
         }
 
         public void nextFrame()