VideoHandle.cs 1.4 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 bbiwarg.InputProviders;
  7. namespace bbiwarg
  8. {
  9. class VideoHandle
  10. {
  11. private IInputProvider inputProvider;
  12. private InputFrame inputFrame;
  13. private DepthImage depthImage;
  14. public VideoHandle(IInputProvider inputProvider) {
  15. this.inputProvider = inputProvider;
  16. }
  17. public void start() {
  18. inputProvider.init();
  19. inputProvider.start();
  20. inputProvider.updateFrame();
  21. inputFrame = inputProvider.getInputFrame();
  22. depthImage = inputFrame.getDepthImage();
  23. }
  24. public void stop() {
  25. inputProvider.stop();
  26. }
  27. public void nextFrame()
  28. {
  29. if (inputProvider.isActive())
  30. {
  31. inputProvider.releaseFrame();
  32. inputProvider.updateFrame();
  33. inputFrame = inputProvider.getInputFrame();
  34. depthImage = inputFrame.getDepthImage();
  35. }
  36. else
  37. {
  38. inputProvider.stop();
  39. }
  40. }
  41. public int getWidth()
  42. {
  43. return inputFrame.getWidth();
  44. }
  45. public int getHeight()
  46. {
  47. return inputFrame.getHeight();
  48. }
  49. public DepthImage getDepthImage() {
  50. return depthImage;
  51. }
  52. }
  53. }