Browse Source

Added ImageData.
Changed ColorImage to give access to Color4 instead of a,r,g,b.

Daniel Kauth 11 years ago
parent
commit
e97dfd22dd
3 changed files with 60 additions and 18 deletions
  1. 3 18
      bbiwarg/DataSource/ColorImage.cs
  2. 56 0
      bbiwarg/DataSource/ImageData.cs
  3. 1 0
      bbiwarg/bbiwarg.csproj

+ 3 - 18
bbiwarg/DataSource/ColorImage.cs

@@ -28,25 +28,10 @@ namespace bbiwarg.DataSource
             return height;
         }
 
-        public byte getR(int x, int y)
+        public Color4 getColor(int x, int y)
         {
-            return data[4 * (y * width + x) + 0];
+            return new Color4(data[4 * (y * width + x) + 3], data[4 * (y * width + x) + 0], 
+                              data[4 * (y * width + x) + 1], data[4 * (y * width + x) + 2]);
         }
-
-        public byte getG(int x, int y)
-        {
-            return data[4 * (y * width + x) + 1];
-        }
-
-        public byte getB(int x, int y)
-        {
-            return data[4 * (y * width + x) + 2];
-        }
-
-        public byte getA(int x, int y)
-        {
-            return data[4 * (y * width + x) + 3];
-        }
-
     }
 }

+ 56 - 0
bbiwarg/DataSource/ImageData.cs

@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace bbiwarg.DataSource
+{
+    /**
+     * Gives access to all important data in depth image coordinates.
+     */
+    class ImageData
+    {
+        private DepthImage depthImage;
+        private ConfidenceImage confidenceImage;
+        private ColorImage colorImage;
+        private UVImage uvImage;
+
+        public ImageData(DepthImage depthImage, ConfidenceImage confidenceImage, ColorImage colorImage, UVImage uvImage)
+        {
+            this.depthImage = depthImage;
+            this.confidenceImage = confidenceImage;
+            this.colorImage = colorImage;
+            this.uvImage = uvImage;
+        }
+
+        public int getWidth()
+        {
+            return depthImage.getWidth();
+        }
+
+        public int getHeight()
+        {
+            return depthImage.getHeight();
+        }
+
+        public short getDepth(int x, int y)
+        {
+            return depthImage.getDepth(x, y);
+        }
+
+        public float getConfidence(int x, int y)
+        {
+            return confidenceImage.getConfidence(x, y);
+        }
+
+        public Color4 getColor(int x, int y)
+        {
+            float u = uvImage.getU(x, y);
+            float v = uvImage.getV(x, y);
+            int xInColorImage = (int) u * colorImage.getWidth();
+            int yInColorImage = (int) v * colorImage.getHeight();
+            return colorImage.getColor(xInColorImage, yInColorImage);
+        }
+    }
+}

+ 1 - 0
bbiwarg/bbiwarg.csproj

@@ -56,6 +56,7 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="DataSource\ImageData.cs" />
     <Compile Include="DataSource\UVImage.cs" />
     <Compile Include="DataSource\Color4.cs" />
     <Compile Include="DataSource\ColorImage.cs" />