ImageData.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. int xInColorImage = (int) u * colorImage.getWidth();
  46. int yInColorImage = (int) v * colorImage.getHeight();
  47. return colorImage.getColor(xInColorImage, yInColorImage);
  48. }
  49. }
  50. }