using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Drawing; 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 short getConfidence(int x, int y) { return confidenceImage.getConfidence(x, y); } public Color getColor(int x, int y) { float u = uvImage.getU(x, y); float v = uvImage.getV(x, y); if (u < 0 || v < 0) return Color.Black; int xInColorImage = (int) (u * colorImage.getWidth()) % colorImage.getWidth(); int yInColorImage = (int) (v * colorImage.getHeight()) % colorImage.getHeight(); return colorImage.getColor(xInColorImage, yInColorImage); } } }