TestDataSource.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Drawing;
  3. using MathNet.Numerics.LinearAlgebra.Single;
  4. using bbiwarg.DataSource;
  5. namespace bbiwarg.Test
  6. {
  7. class TestDataSource
  8. {
  9. static void Main(string[] args)
  10. {
  11. IVideoDataSource source = new IIsuDataSource("..\\..\\videos\\2.skv");
  12. source.init();
  13. source.start();
  14. int i = 0;
  15. int j = 0;
  16. while (source.isActive())
  17. {
  18. source.updateFrame();
  19. if ((i % 30) == 0)
  20. {
  21. DataSource.DepthImage image = source.getDepthImage();
  22. Bitmap bm = new Bitmap(image.getWidth(), image.getHeight());
  23. for (int x = 0; x < image.getWidth(); ++x)
  24. {
  25. for (int y = 0; y < image.getHeight(); ++y)
  26. {
  27. int value = (int)(image.getDepth(x, y) / 1000.0 * 255.0) % 256;
  28. bm.SetPixel(x, y, Color.FromArgb(255, value, value, value));
  29. }
  30. }
  31. Vector palmPosition2D = source.getPalmPosition2D(1);
  32. bm.SetPixel((int)palmPosition2D[0], (int)palmPosition2D[1], Color.Yellow);
  33. bm.Save("test." + j + ".png");
  34. j++;
  35. }
  36. source.releaseFrame();
  37. ++i;
  38. }
  39. source.stop();
  40. }
  41. }
  42. }