Browse Source

Merge branch 'master' of https://git.tk.informatik.tu-darmstadt.de/etri-smartspaces

Conflicts:
	bbiwarg.v11.suo
	bbiwarg/OutputTest.cs
	bbiwarg/bbiwarg.csproj
Alexander Hendrich 11 years ago
parent
commit
7262701f8b

BIN
bbiwarg.v11.suo


+ 12 - 0
bbiwarg/DataSource/ColorImage.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace bbiwarg.DataSource
+{
+    class ColorImage
+    {
+    }
+}

+ 7 - 4
bbiwarg/DepthImage.cs → bbiwarg/DataSource/DepthImage.cs

@@ -4,14 +4,17 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace bbiwarg
+namespace bbiwarg.DataSource
 {
+    /**
+     * Represents an depth image where the depth is given in distance to the camera in millimeters. 
+     */
     class DepthImage
     {
         private int width, height;
-        private ushort[] data;
+        private short[] data;
 
-        public DepthImage(int width, int height, ushort[] data)
+        public DepthImage(int width, int height, short[] data)
         {
             this.width = width;
             this.height = height;
@@ -28,7 +31,7 @@ namespace bbiwarg
             return height;
         }
 
-        public ushort getDepth(int x, int y)
+        public short getDepth(int x, int y)
         {
             return data[y * width + x];
         }

+ 5 - 2
bbiwarg/DataSource/IVideoDataSource.cs

@@ -2,7 +2,7 @@
 
 using MathNet.Numerics.LinearAlgebra.Single;
 
-namespace bbiwarg
+namespace bbiwarg.DataSource
 {
     public enum FingerStatus
     {
@@ -54,8 +54,11 @@ namespace bbiwarg
          */
         bool isActive();
         int getFrameRate();
+        /**
+         * The depth is given by the distance to the camera in millimeters. 
+         */
         DepthImage getDepthImage();
-
+        ColorImage getColorImage();
         /*
          * all handIndices have to be 1 or 2
          */

+ 18 - 6
bbiwarg/DataSource/IisuDataSource.cs

@@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
 using Iisu;
 using MathNet.Numerics.LinearAlgebra.Single;
 
-namespace bbiwarg
+namespace bbiwarg.DataSource
 {
     class IIsuDataSource: IVideoDataSource
     {
@@ -26,6 +26,7 @@ namespace bbiwarg
         private IDataHandle<Iisu.Data.Vector3[]>[] fingerTipPositions3D = new IDataHandle<Iisu.Data.Vector3[]>[2];
         private IDataHandle<int>[] handSides = new IDataHandle<int>[2];
         private IDataHandle<Iisu.Data.IImageData> depthImage;
+        private IDataHandle<Iisu.Data.IImageData> colorImage;
 
         /*
          * Creates an Iisu data source.
@@ -58,6 +59,8 @@ namespace bbiwarg
             
             // data
             depthImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.DEPTH.Image");
+
+            colorImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.COLOR.Image");
             
             handOpen[0] = device.RegisterDataHandle<bool>("CI.HAND1.IsOpen");
             handOpen[1] = device.RegisterDataHandle<bool>("CI.HAND2.IsOpen");
@@ -128,13 +131,22 @@ namespace bbiwarg
 
             IntPtr imageData = depthImage.Value.Raw;
             
-            short[] tmp = new short[width * height];
-            Marshal.Copy(imageData, tmp, 0, width * height);
+            short[] depthData = new short[width * height];
+            Marshal.Copy(imageData, depthData, 0, width * height);
+
+            return new DepthImage(width, height, depthData);
+        }
+
+        public ColorImage getColorImage()
+        {
+            Iisu.Data.IImageInfos imageInfos = depthImage.Value.ImageInfos;
+            int width = (int)imageInfos.Width;
+            int height = (int)imageInfos.Height;
+            int numBytes = (int)imageInfos.BytesRaw;
 
-            ushort[] data = new ushort[width * height];
-            Buffer.BlockCopy(tmp, 0, data, 0, numBytes);
+            Console.WriteLine("width: " + width + " height: " + height + " numBytes: " + numBytes);
 
-            return new DepthImage(width, height, data);
+            return new ColorImage();
         }
 
         private void checkHandIndex(uint handIndex) 

+ 20 - 0
bbiwarg/OutputTest.cs

@@ -0,0 +1,20 @@
+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)
+        {
+            DataSource.IVideoDataSource source = new DataSource.IIsuDataSource("..\\..\\videos\\1.skv");
+
+            source.init();
+            source.start();
+
+        }
+    }
+}

+ 5 - 5
bbiwarg/TestDataSource.cs

@@ -8,7 +8,7 @@ namespace bbiwarg
     {
         static void Main(string[] args)
         {
-            IVideoDataSource source = new IIsuDataSource("..\\..\\videos\\1.skv");
+            DataSource.IVideoDataSource source = new DataSource.IIsuDataSource("..\\..\\videos\\2.skv");
 
             source.init();
             source.start();
@@ -21,20 +21,20 @@ namespace bbiwarg
 
                 if ((i % 30) == 0)
                 {
-                    DepthImage image = source.getDepthImage();
+                    DataSource.ColorImage image = source.getColorImage();
 
-                    Bitmap bm = new Bitmap(image.getWidth(), image.getHeight());
+                    /*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 = (image.getDepth(x, y) / 4) % 256; // / 4 because most values are small (< 1024)
+                            int value = (int) (image.getDepth(x, y) / 1000.0 * 255.0) % 256;
                             bm.SetPixel(x, y, Color.FromArgb(255, value, value, value));
                         }
                     }
 
                     bm.Save("test." + j + ".png");
-                    j++;
+                    j++;*/
                 }
 
                 source.releaseFrame();

+ 5 - 2
bbiwarg/bbiwarg.csproj

@@ -56,10 +56,13 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="OutputTest\OutputTest.cs" />
-    <Compile Include="DepthImage.cs" />
+    <Compile Include="DataSource\ColorImage.cs" />
+    <Compile Include="DataSource\DepthImage.cs" />
     <Compile Include="DataSource\IisuDataSource.cs" />
     <Compile Include="DataSource\IVideoDataSource.cs" />
+    <Compile Include="OutputTest.cs">
+      <SubType>Code</SubType>
+    </Compile>
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="TestDataSource.cs" />
   </ItemGroup>