|
@@ -1,132 +1,132 @@
|
|
|
-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;
|
|
|
-
|
|
|
-using bbiwarg.DataSource;
|
|
|
-
|
|
|
-namespace bbiwarg.Test
|
|
|
-{
|
|
|
- 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\\1.skv");
|
|
|
- source.init();
|
|
|
- source.start();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- protected override void OnLoad(EventArgs e)
|
|
|
- {
|
|
|
- base.OnLoad(e);
|
|
|
- Title = "OutputTest";
|
|
|
- GL.ClearColor(Color.Black);
|
|
|
- }
|
|
|
-
|
|
|
- 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);
|
|
|
+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;
|
|
|
+
|
|
|
+using bbiwarg.DataSource;
|
|
|
+
|
|
|
+namespace bbiwarg.Test
|
|
|
+{
|
|
|
+ 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\\1.skv");
|
|
|
+ source.init();
|
|
|
+ source.start();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void OnLoad(EventArgs e)
|
|
|
+ {
|
|
|
+ base.OnLoad(e);
|
|
|
+ Title = "OutputTest";
|
|
|
+ GL.ClearColor(Color.Black);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
|
|
|
- GL.Color3(1.0f,1.0f,1.0f);
|
|
|
-
|
|
|
- DepthImage depthImage = source.getDepthImage();
|
|
|
- ConfidenceImage confidenceImage = source.getConfidenceImage();
|
|
|
- int width = depthImage.getWidth();
|
|
|
- int height = depthImage.getHeight();
|
|
|
-
|
|
|
- for (int x = 0; x < width-1; x++) {
|
|
|
- for (int y = 0; y < height-1; y++)
|
|
|
- {
|
|
|
- short confidence = confidenceImage.getConfidence(x,y);
|
|
|
-
|
|
|
- if(confidence > 100) {
|
|
|
- short depth = depthImage.getDepth(x, y);
|
|
|
-
|
|
|
-
|
|
|
- int relX = x - width / 2;
|
|
|
- int relY = height/2 - y;
|
|
|
-
|
|
|
- GL.Begin(BeginMode.Polygon);
|
|
|
- GL.Vertex3(relX-0.5f, relY+0.5f, -depth);
|
|
|
- GL.Vertex3(relX+0.5f, relY+0.5f, -depth);
|
|
|
- GL.Vertex3(relX+0.5f, relY-0.5f, -depth);
|
|
|
- GL.Vertex3(relX-0.5f, relY-0.5f, -depth);
|
|
|
- GL.End();
|
|
|
- }
|
|
|
- }
|
|
|
+ GL.Color3(1.0f,1.0f,1.0f);
|
|
|
+
|
|
|
+ DepthImage depthImage = source.getDepthImage();
|
|
|
+ ConfidenceImage confidenceImage = source.getConfidenceImage();
|
|
|
+ int width = depthImage.getWidth();
|
|
|
+ int height = depthImage.getHeight();
|
|
|
+
|
|
|
+ for (int x = 0; x < width-1; x++) {
|
|
|
+ for (int y = 0; y < height-1; y++)
|
|
|
+ {
|
|
|
+ short confidence = confidenceImage.getConfidence(x,y);
|
|
|
+
|
|
|
+ if(confidence > 100) {
|
|
|
+ short depth = depthImage.getDepth(x, y);
|
|
|
+
|
|
|
+
|
|
|
+ int relX = x - width / 2;
|
|
|
+ int relY = height/2 - y;
|
|
|
+
|
|
|
+ GL.Begin(BeginMode.Polygon);
|
|
|
+ GL.Vertex3(relX-0.5f, relY+0.5f, -depth);
|
|
|
+ GL.Vertex3(relX+0.5f, relY+0.5f, -depth);
|
|
|
+ GL.Vertex3(relX+0.5f, relY-0.5f, -depth);
|
|
|
+ GL.Vertex3(relX-0.5f, relY-0.5f, -depth);
|
|
|
+ GL.End();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- //Triangle triangle = new Triangle(new DenseVector(new float[] { 0.0f, 0.0f, -100.0f }), new DenseVector(new float[] { 100.0f, 0.0f, -100.0f }), new DenseVector(new float[] { 0.0f, 100.0f, -100.0f }));
|
|
|
-
|
|
|
- /*
|
|
|
- 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, 3000.0f);
|
|
|
- GL.MatrixMode(MatrixMode.Projection);
|
|
|
- GL.LoadMatrix(ref projection);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+ //Triangle triangle = new Triangle(new DenseVector(new float[] { 0.0f, 0.0f, -100.0f }), new DenseVector(new float[] { 100.0f, 0.0f, -100.0f }), new DenseVector(new float[] { 0.0f, 100.0f, -100.0f }));
|
|
|
+
|
|
|
+ /*
|
|
|
+ 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, 3000.0f);
|
|
|
+ GL.MatrixMode(MatrixMode.Projection);
|
|
|
+ GL.LoadMatrix(ref projection);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|