ImageData.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Drawing;
  7. namespace bbiwarg.DataSource
  8. {
  9. /**
  10. * Gives access to all important data in depth image coordinates.
  11. */
  12. class ImageData
  13. {
  14. private DepthImage depthImage;
  15. private ConfidenceImage confidenceImage;
  16. private ColorImage colorImage;
  17. private UVImage uvImage;
  18. public ImageData(DepthImage depthImage, ConfidenceImage confidenceImage, ColorImage colorImage, UVImage uvImage)
  19. {
  20. this.depthImage = depthImage;
  21. this.confidenceImage = confidenceImage;
  22. this.colorImage = colorImage;
  23. this.uvImage = uvImage;
  24. }
  25. public int getWidth()
  26. {
  27. return depthImage.getWidth();
  28. }
  29. public int getHeight()
  30. {
  31. return depthImage.getHeight();
  32. }
  33. public short getDepth(int x, int y)
  34. {
  35. return depthImage.getDepth(x, y);
  36. }
  37. public short getConfidence(int x, int y)
  38. {
  39. return confidenceImage.getConfidence(x, y);
  40. }
  41. public Color getColor(int x, int y)
  42. {
  43. float u = uvImage.getU(x, y);
  44. float v = uvImage.getV(x, y);
  45. if (u < 0 || v < 0)
  46. return Color.Black;
  47. int xInColorImage = (int) (u * colorImage.getWidth()) % colorImage.getWidth();
  48. int yInColorImage = (int) (v * colorImage.getHeight()) % colorImage.getHeight();
  49. return colorImage.getColor(xInColorImage, yInColorImage);
  50. }
  51. }
  52. }