Browse Source

implemented outputTest

Alexander Hendrich 10 years ago
parent
commit
d7e16cf3ed
5 changed files with 123 additions and 27 deletions
  1. 0 6
      bbiwarg.sln
  2. BIN
      bbiwarg.v11.suo
  3. 0 20
      bbiwarg/OutputTest.cs
  4. 122 0
      bbiwarg/OutputTest/OutputTest.cs
  5. 1 1
      bbiwarg/bbiwarg.csproj

+ 0 - 6
bbiwarg.sln

@@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio 2012
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bbiwarg", "bbiwarg\bbiwarg.csproj", "{12271049-82D6-436D-A51E-E6614C8E9C50}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bbiwargOutputTest", "bbiwargOutputTest\bbiwargOutputTest.csproj", "{81A86DAA-B131-4974-8F02-56B5005ABE90}"
-EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -15,10 +13,6 @@ Global
 		{12271049-82D6-436D-A51E-E6614C8E9C50}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{12271049-82D6-436D-A51E-E6614C8E9C50}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{12271049-82D6-436D-A51E-E6614C8E9C50}.Release|Any CPU.Build.0 = Release|Any CPU
-		{81A86DAA-B131-4974-8F02-56B5005ABE90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{81A86DAA-B131-4974-8F02-56B5005ABE90}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{81A86DAA-B131-4974-8F02-56B5005ABE90}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{81A86DAA-B131-4974-8F02-56B5005ABE90}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

BIN
bbiwarg.v11.suo


+ 0 - 20
bbiwarg/OutputTest.cs

@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace bbiwarg
-{
-    class OutputTest
-    {
-        static void Main(string[] args)
-        {
-            IVideoDataSource source = new IIsuDataSource("..\\..\\videos\\1.skv");
-
-            source.init();
-            source.start();
-
-        }
-    }
-}

+ 122 - 0
bbiwarg/OutputTest/OutputTest.cs

@@ -0,0 +1,122 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Drawing;
+using OpenTK;
+using OpenTK.Graphics.OpenGL;
+using MathNet.Numerics.LinearAlgebra.Single;
+namespace bbiwarg
+{
+    class OutputTest : GameWindow
+    {
+        IVideoDataSource source;
+
+        static void Main(string[] args)
+        {
+            OutputTest demo = new OutputTest();
+            demo.initSource();
+            demo.Run(30);
+        }
+
+
+        public void initSource()
+        {
+            source = new IIsuDataSource("..\\..\\videos\\10.skv");
+            source.init();
+            source.start();
+
+        }
+
+        protected override void OnLoad(EventArgs e)
+        {
+            base.OnLoad(e);
+            Title = "OutputTest";
+            GL.ClearColor(Color.CornflowerBlue);
+        }
+
+        protected override void OnRenderFrame(FrameEventArgs e)
+        {
+            base.OnRenderFrame(e);
+
+            bool isActive = source.isActive();
+            if (isActive)
+            {
+                source.updateFrame();
+            }
+
+            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
+            Matrix4 modelview = Matrix4.LookAt(Vector3.Zero, -Vector3.UnitZ, Vector3.UnitY);
+            GL.MatrixMode(MatrixMode.Modelview);
+            GL.LoadMatrix(ref modelview);
+
+            
+            
+            DepthImage depthImage = source.getDepthImage();
+            int width = depthImage.getWidth();
+            int height = depthImage.getHeight();
+
+            for (int x = 0; x < width; x++) {
+                for (int y = 0; y < height; y++) {
+                    ushort depth = depthImage.getDepth(x, y);
+                    int depth2 = depth;
+                    //depth = 60;
+
+                    int relX = x - width / 2;
+                    int relY = y - height / 2;
+
+                    GL.Begin(BeginMode.Polygon);
+                    GL.Vertex3(relX-0.5f, relY+0.5f, -depth2);
+                    GL.Vertex3(relX+0.5f, relY+0.5f, -depth2);
+                    GL.Vertex3(relX+0.5f, relY-0.5f, -depth2);
+                    GL.Vertex3(relX-0.5f, relY-0.5f, -depth2);
+                    GL.End();
+                }
+            }
+
+            /*
+            GL.Begin(BeginMode.Triangles);
+            GL.Vertex3(0.0f, 0.0f, -4.0f);
+            GL.Vertex3(2.0f, 0.0f, -4.0f);
+            GL.Vertex3(0.0f, 1.0f, -4.0f);
+            GL.End();
+            */
+            SwapBuffers();
+
+            if(isActive) {
+                source.releaseFrame();
+            }
+
+
+            /*
+            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
+
+            Matrix4 modelview = Matrix4.LookAt(Vector3.Zero, Vector3.UnitZ, Vector3.UnitY);
+            GL.MatrixMode(MatrixMode.Modelview);
+            GL.LoadMatrix(ref modelview);
+
+            // triangle
+            GL.Begin(BeginMode.Triangles);
+
+            float x = palmPosition.Value._X;
+            float y = palmPosition.Value._Y;
+            float z = palmPosition.Value._Z;
+
+            GL.Vertex3(-1.0f + x, -1.0f + z, 4.0f - 10 * y);
+            GL.Vertex3(1.0f, -1.0f, 4.0f);
+            GL.Vertex3(0.0f, 1.0f, 4.0f);
+            GL.End();
+
+            SwapBuffers();*/
+        }
+
+        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, 640.0f);
+            GL.MatrixMode(MatrixMode.Projection);
+            GL.LoadMatrix(ref projection);
+        }
+    }
+}

+ 1 - 1
bbiwarg/bbiwarg.csproj

@@ -56,7 +56,7 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="OutputTest.cs" />
+    <Compile Include="OutputTest\OutputTest.cs" />
     <Compile Include="DepthImage.cs" />
     <Compile Include="DataSource\IisuDataSource.cs" />
     <Compile Include="DataSource\IVideoDataSource.cs" />