EdgeImage.cs 1019 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. namespace bbiwarg.Images
  11. {
  12. class EdgeImage
  13. {
  14. public Image<Gray, Byte> Image {get; private set;}
  15. public EdgeImage(DepthImage depthImage) {
  16. Image = depthImage.Image.Canny(100, 75, 3);
  17. }
  18. public EdgeImage(Image<Gray, Byte> edgeImage) {
  19. Image = edgeImage;
  20. }
  21. public bool isEdgeAt(Point point) {
  22. return isEdgeAt(point.X, point.Y);
  23. }
  24. public bool isEdgeAt(int x, int y) {
  25. return (Image.Data[y,x,0] > 0);
  26. }
  27. public void removeFingerEdges(Finger finger) {
  28. Point[] polygon = finger.getPolygon();
  29. Image.FillConvexPoly(polygon, new Gray(0));
  30. }
  31. public EdgeImage copy() {
  32. return new EdgeImage(Image.Copy());
  33. }
  34. }
  35. }