Bläddra i källkod

testDataSource writes bitmaps with depthmap+palmPosition

Alexander Hendrich 11 år sedan
förälder
incheckning
61f3293edc
2 ändrade filer med 26 tillägg och 5 borttagningar
  1. 2 3
      bbiwarg/Test/OutputTest.cs
  2. 24 2
      bbiwarg/Test/TestDataSource.cs

+ 2 - 3
bbiwarg/Test/OutputTest.cs

@@ -87,8 +87,6 @@ namespace bbiwarg.Test
             Vector palm = source.getPalmPosition2D(1);
             Vector[] fingers = source.getFingerTipPositions2D(1);
 
-            Console.WriteLine(fingers[0][0]);
-
             Pixel3D palmPosition = new Pixel3D((int)palm[0], (int)palm[1], width, height);
             Pixel3D finger1Position = new Pixel3D((int)fingers[0][0], (int)fingers[0][1], width, height);
             palmPosition.depth = depthImage.getDepth((int)palm[0], (int)palm[1]);
@@ -115,8 +113,9 @@ namespace bbiwarg.Test
         protected override void OnResize(EventArgs e)
         {
             base.OnResize(e);
+
             GL.Viewport(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height);
-            Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, Width / (float)Height, 1.0f, 3000.0f);
+            Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float) Math.PI/8, Width / (float)Height, 1.0f, 3000.0f);
             GL.MatrixMode(MatrixMode.Projection);
             GL.LoadMatrix(ref projection);
         }

+ 24 - 2
bbiwarg/Test/TestDataSource.cs

@@ -1,6 +1,6 @@
 using System;
-
 using System.Drawing;
+using MathNet.Numerics.LinearAlgebra.Single;
 
 using bbiwarg.DataSource;
 
@@ -21,9 +21,31 @@ namespace bbiwarg.Test
             {
                 source.updateFrame();
 
+                if ((i % 30) == 0)
+                {
+                    DataSource.DepthImage image = source.getDepthImage();
+
+                    Bitmap bm = new Bitmap(image.getWidth(), image.getHeight());
+                    for (int x = 0; x < image.getWidth(); ++x)
+                    {
+                        for (int y = 0; y < image.getHeight(); ++y)
+                        {
+                            int value = (int)(image.getDepth(x, y) / 1000.0 * 255.0) % 256;
+                            bm.SetPixel(x, y, Color.FromArgb(255, value, value, value));
+                        }
+                    }
+
+                    Vector palmPosition2D = source.getPalmPosition2D(1);
+
+                    bm.SetPixel((int)palmPosition2D[0], (int)palmPosition2D[1], Color.Yellow);
+
+                    bm.Save("test." + j + ".png");
+                    j++;
+                }
+
                 source.releaseFrame();
+                ++i;
             }
-
             source.stop();
         }
     }