Browse Source

added Dispose to OutputImage

Alexander Hendrich 11 years ago
parent
commit
b182fdef8f

+ 3 - 0
bbiwarg/Output/DebugOutput/DebugImages.cs

@@ -28,6 +28,9 @@ namespace bbiwarg.Output.DebugOutput
 
         public void updateImages(FrameData frameData)
         {
+            foreach (OutputImage image in Images)
+                image.Dispose();
+
             Images.Clear();
 
             Images.Add(getDepthImage(frameData));

+ 7 - 17
bbiwarg/Output/GlassesOutput/GlassesWindow.cs

@@ -34,14 +34,7 @@ namespace bbiwarg.Output.GlassesOutput
             base.OnLoad(e);
             Title = Parameters.GlassesWindowTitle;
             GL.ClearColor(Color.Black);
-            /*
-            // transparency
-            GL.Enable(EnableCap.Blend);
-            GL.BlendEquation(BlendEquationMode.Max);
-
-            // Depth Test 
-            GL.Enable(EnableCap.DepthTest);
-            */
+
             // Texture
             GL.Enable(EnableCap.Texture2D);
             GL.GenTextures(1, out textureID);
@@ -65,14 +58,9 @@ namespace bbiwarg.Output.GlassesOutput
 
             int screenWidth = ClientRectangle.Width;
             int screenHeight = ClientRectangle.Height;
-            /*
-            int numRows = 1 + (Parameters.DebugWindowNumImages - 1) / Parameters.DebugWindowNumImagesPerRow;
-            int numCols = Math.Min(Parameters.DebugWindowNumImages, Parameters.DebugWindowNumImagesPerRow);
-            int heightForWidth = (int)((float)screenWidth / ((float)numCols * Parameters.ImageAspectRatio) * (float)numRows);
-            */
-            GL.Viewport(0, 0, screenWidth, screenHeight);
-            //GL.Viewport(0, (screenHeight - heightForWidth) / 2, screenWidth, heightForWidth);
 
+            GL.Viewport(0, 0, screenWidth, screenHeight);
+            
             //Matrix4 projection = Matrix4.CreateOrthographicOffCenter(0, numCols, numRows, 0, 0.001f, 10f);
             Matrix4 projection = Matrix4.CreateOrthographicOffCenter(0, 1, 1, 0, 0.001f, 10f);
             GL.MatrixMode(MatrixMode.Projection);
@@ -98,6 +86,8 @@ namespace bbiwarg.Output.GlassesOutput
 
                         Timer.start("GlassesWindow.OnUpdateFrame::updateImage");
                         //TODO update image
+                        if (image != null)
+                            image.Dispose();
                         image = new OutputImage(Parameters.GlassesWindowWidth, Parameters.GlassesWindowHeight);
                         Timer.stop("GlassesWindow.OnUpdateFrame::updateImage");
                     }
@@ -124,7 +114,7 @@ namespace bbiwarg.Output.GlassesOutput
             Timer.start("GlassesWindow.OnRenderFrame::drawImage");
             
             GL.BindTexture(TextureTarget.Texture2D, textureID);
-            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb, Parameters.ImageWidth, Parameters.ImageHeight, 0, PixelFormat.Rgb, PixelType.UnsignedByte, image.Image.MIplImage.imageData);
+            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb, Parameters.GlassesWindowWidth, Parameters.GlassesWindowHeight, 0, PixelFormat.Rgb, PixelType.UnsignedByte, image.Image.MIplImage.imageData);
             GL.Begin(PrimitiveType.Quads);
             GL.Color3(1.0, 1.0, 1.0);
             GL.TexCoord2(0, 0); GL.Vertex3(0, 0, -1);
@@ -144,7 +134,7 @@ namespace bbiwarg.Output.GlassesOutput
 
         private void handleKeyDown(object sender, KeyboardKeyEventArgs e)
         {
-            Console.WriteLine("jens ist plööhöhöhöhööt");
+
         }
 
     }

+ 6 - 1
bbiwarg/Output/OutputImage.cs

@@ -11,7 +11,7 @@ using Emgu.CV.Structure;
 
 namespace bbiwarg.Output
 {
-    class OutputImage
+    class OutputImage : IDisposable
     {
         public Image<Rgb, byte> Image { get; private set; }
 
@@ -155,5 +155,10 @@ namespace bbiwarg.Output
             Vector2D lastPos = positions[numPositions - 1].scale(maxPixel);
             fillCircle(lastPos.IntX, lastPos.IntY, 3, pointColorFaded);
         }
+
+        public void Dispose()
+        {
+            Image.Dispose();
+        }
     }
 }

+ 1 - 1
bbiwarg/Parameters.cs

@@ -19,7 +19,7 @@ namespace bbiwarg
     class Parameters
     {
         // input
-        public static readonly InputType InputSource = InputType.Camera;
+        public static readonly InputType InputSource = InputType.Movie;
         public static readonly String InputMoviePath = "..\\..\\videos\\touch\\4.skv";
 
         // Logger