1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Emgu.CV;
- using Emgu.CV.Structure;
- using bbiwarg.Detectors.FingerDetection;
- using System.Diagnostics;
- using bbiwarg.Utility;
- using bbiwarg.Graphics;
- namespace bbiwarg.Images
- {
- class EdgeImage
- {
- public Image<Gray, Byte> Image { get; private set; }
- public Image<Gray, byte> RoughImage { get; private set; }
- public EdgeImage(DepthImage depthImage)
- {
- Image = (depthImage.Image * (255.0f / (float)(depthImage.MaxDepth - depthImage.MinDepth))).Canny(Constants.EdgeImageCannyStartThreshold, Constants.EdgeImageCannyLinkingThreshold, Constants.EdgeImageCannySize).ThresholdBinary(new Gray(0), new Gray(1));
- RoughImage = Image.Dilate(Constants.EdgeImageRoughNumDilationIterations);
- }
- public EdgeImage(Image<Gray, Byte> edgeImage)
- {
- Image = edgeImage;
- RoughImage = Image.Dilate(Constants.EdgeImageRoughNumDilationIterations);
- }
- public bool isEdgeAt(Point point)
- {
- return isEdgeAt(point.X, point.Y);
- }
- public bool isEdgeAt(int x, int y)
- {
- return (Image.Data[y, x, 0] > 0);
- }
- public bool isRoughEdgeAt(Point point)
- {
- return isRoughEdgeAt(point.X, point.Y);
- }
- public bool isRoughEdgeAt(int x, int y)
- {
- return (RoughImage.Data[y, x, 0] > 0);
- }
- public void removeEdgesInsidePolygon(Point[] polygon)
- {
- Image.FillConvexPoly(polygon, new Gray(0));
- }
- public EdgeImage copy()
- {
- return new EdgeImage(Image.Copy());
- }
- public EdgeImage getRoughEdgeImage(int numDilateIterations) {
- return new EdgeImage(Image.Dilate(numDilateIterations));
- }
- }
- }
|