EdgeImage.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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, OutputImage outputImage)
  18. {
  19. // no more scaling to [0, 255]?
  20. Image = depthImage.Image.Canny(100, 75, 3);
  21. // draw blue edges in outputImage
  22. outputImage.Image[2] = Image.ThresholdBinary(new Gray(0), new Gray(1)).Mul(255);
  23. }
  24. public EdgeImage(Image<Gray, Byte> edgeImage)
  25. {
  26. Image = edgeImage;
  27. }
  28. public bool isEdgeAt(Point point)
  29. {
  30. return isEdgeAt(point.X, point.Y);
  31. }
  32. public bool isEdgeAt(int x, int y)
  33. {
  34. return (Image.Data[y, x, 0] > 0);
  35. }
  36. public void removeFingerEdges(Finger finger)
  37. {
  38. Point[] polygon = finger.getPolygon();
  39. Image.FillConvexPoly(polygon, new Gray(0));
  40. }
  41. public EdgeImage copy()
  42. {
  43. return new EdgeImage(Image.Copy());
  44. }
  45. }
  46. }