EdgeImage.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Emgu.CV;
  8. using Emgu.CV.Structure;
  9. using bbiwarg.Detectors.Fingers;
  10. using System.Diagnostics;
  11. using bbiwarg.Utility;
  12. namespace bbiwarg.Images
  13. {
  14. class EdgeImage
  15. {
  16. public Image<Gray, Byte> Image { get; private set; }
  17. public EdgeImage(DepthImage depthImage)
  18. {
  19. // no more scaling to [0, 255]?
  20. Image = depthImage.Image.Canny(100, 75, 3);
  21. }
  22. public EdgeImage(Image<Gray, Byte> edgeImage)
  23. {
  24. Image = edgeImage;
  25. }
  26. public bool isEdgeAt(Point point)
  27. {
  28. return isEdgeAt(point.X, point.Y);
  29. }
  30. public bool isEdgeAt(int x, int y)
  31. {
  32. return (Image.Data[y, x, 0] > 0);
  33. }
  34. public void removeFingerEdges(Finger finger)
  35. {
  36. Point[] polygon = finger.getPolygon();
  37. Image.FillConvexPoly(polygon, new Gray(0));
  38. }
  39. public EdgeImage copy()
  40. {
  41. return new EdgeImage(Image.Copy());
  42. }
  43. }
  44. }