Browse Source

Merge remote-tracking branch 'origin/master'

Anton 11 years ago
parent
commit
e57ca7f770

+ 39 - 0
bbiwarg/DataSource/Color4.cs

@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace bbiwarg.DataSource
+{
+    class Color4
+    {
+        private byte a, r, g, b;
+
+        public Color4(byte a, byte r, byte g, byte b)
+        {
+            this.a = a;
+            this.r = r;
+            this.g = g;
+            this.b = b;
+        }
+
+        public byte getA()
+        {
+            return a;
+        }
+
+        public byte getR()
+        {
+            return r;
+        }
+        public byte getG()
+        {
+            return g;
+        }
+        public byte getB()
+        {
+            return b;
+        }
+    }
+}

+ 1 - 0
bbiwarg/DataSource/IVideoDataSource.cs

@@ -60,6 +60,7 @@ namespace bbiwarg.DataSource
         DepthImage getDepthImage();
         ColorImage getColorImage();
         ConfidenceImage getConfidenceImage();
+        VertexArray getVertexArray();
         /*
          * all handIndices have to be 1 or 2
          */

+ 20 - 3
bbiwarg/DataSource/IisuDataSource.cs

@@ -28,6 +28,7 @@ namespace bbiwarg.DataSource
         private IDataHandle<Iisu.Data.IImageData> depthImage;
         private IDataHandle<Iisu.Data.IImageData> colorImage;
         private IDataHandle<Iisu.Data.IImageData> confidenceImage;
+        private IDataHandle<Iisu.Data.Vertex[]> vertexArray;
 
         /*
          * Creates an Iisu data source.
@@ -68,7 +69,8 @@ namespace bbiwarg.DataSource
             depthImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.DEPTH.Image");
             colorImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.COLOR.Image");
             confidenceImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.CONFIDENCE.Image");
-            
+            vertexArray = device.RegisterDataHandle<Iisu.Data.Vertex[]>("SCENE.VertexArray");
+
             handOpen[0] = device.RegisterDataHandle<bool>("CI.HAND1.IsOpen");
             handOpen[1] = device.RegisterDataHandle<bool>("CI.HAND2.IsOpen");
 
@@ -131,8 +133,6 @@ namespace bbiwarg.DataSource
 
         public DepthImage getDepthImage()
         {
-            
-
             Iisu.Data.IImageInfos imageInfos = depthImage.Value.ImageInfos;
             int width = (int) imageInfos.Width;
             int height = (int) imageInfos.Height;
@@ -176,6 +176,23 @@ namespace bbiwarg.DataSource
             return new ConfidenceImage(width, height, confidenceData);
         }
 
+        public VertexArray getVertexArray()
+        {
+            int numVertices = vertexArray.Value.Length;
+
+            Vector[] positions = new Vector[numVertices];
+            Color4[] colors = new Color4[numVertices];
+
+            for (int i = 0; i < numVertices; ++i)
+            {
+                positions[i] = new DenseVector(vertexArray.Value[i].Position.ToArray());
+                Iisu.Data.Color4C color = vertexArray.Value[i].Color;
+                colors[i] = new Color4(color.A, color.R, color.G, color.B);
+            }
+
+            return new VertexArray(positions, colors);
+        }
+
         private void checkHandIndex(uint handIndex) 
         {
             if (handIndex < 1 || handIndex > 2)

+ 37 - 0
bbiwarg/DataSource/VertexArray.cs

@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using MathNet.Numerics.LinearAlgebra.Single;
+
+namespace bbiwarg.DataSource
+{
+    class VertexArray
+    {
+        private Vector[] positions;
+        private Color4[] colors;
+
+        public VertexArray(Vector[] positions, Color4[] colors)
+        {
+            this.positions = positions;
+            this.colors = colors;
+        }
+
+        public int getNumVertices()
+        {
+            return positions.Length;
+        }
+
+        public Vector getPosition(int index)
+        {
+            return positions[index];
+        }
+
+        public Color4 getColor(int index)
+        {
+            return colors[index];
+        }
+    }
+}