ImageData.cs 1.5 KB

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