TouchImage.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Emgu.CV;
  7. using Emgu.CV.Structure;
  8. using bbiwarg.Utility;
  9. namespace bbiwarg.Images
  10. {
  11. public enum TouchImageState
  12. {
  13. none = 0,
  14. touchArea = 1,
  15. touchAreaMatched = 2,
  16. touchAreaStatusBar = 3,
  17. touchDetected = 4,
  18. touchTracked = 5
  19. }
  20. class TouchImage
  21. {
  22. private Image<Gray, byte> image;
  23. private List<Vector2D> oldTouches;
  24. public TouchImage(int width, int height)
  25. {
  26. image = new Image<Gray, byte>(width, height);
  27. oldTouches = new List<Vector2D>();
  28. }
  29. public void setTouchAt(int x, int y, TouchImageState tis)
  30. {
  31. image.Data[y, x, 0] = (byte)tis;
  32. int size = 5;
  33. if (tis == TouchImageState.touchTracked || tis == TouchImageState.touchDetected)
  34. {
  35. image.Draw(new CircleF(new System.Drawing.PointF(x, y), 5), new Gray((byte) tis), 0);
  36. }
  37. }
  38. public TouchImageState getStateAt(int x, int y)
  39. {
  40. return (TouchImageState)image.Data[y, x, 0];
  41. }
  42. }
  43. }