using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Emgu.CV; using Emgu.CV.Structure; using System.Drawing; using bbiwarg.Detectors.Fingers; using bbiwarg.Utility; using bbiwarg.Detectors.Touch; namespace bbiwarg.Images { public enum PalmImageState { none = 0, palmContour = 1, wristLine = 2, thumbLine = 3, palmRect = 4, palmGrid = 5 } class PalmImage { private Image image; public PalmImage(int width, int height) { image = new Image(width, height); } public PalmImageState getStateAt(int x, int y) { return (PalmImageState)image.Data[y, x, 0]; } public void drawContour(Contour contour) { image.Draw(contour.GetConvexHull(Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE), new Gray((byte)PalmImageState.palmContour), 1); //image.Draw(contour, new Gray((byte)PalmImageState.palmContour), 1); } public void drawLine(LineSegment2DF line, PalmImageState state) { image.Draw(line, new Gray((byte)state), 1); } public void drawGrid(Vector2D a, Vector2D b, Vector2D c, Vector2D d) { int columnCount = 4; int rowCount = 3; Vector2D bc = c - b; for (int i = 1; i < columnCount; i++) { Vector2D bci = b + (bc * ((float)i/columnCount)); Vector2D adi = a + (bc * ((float)i/columnCount)); drawLine(new LineSegment2DF(bci, adi), PalmImageState.palmGrid); } Vector2D ab = b - a; for (int i = 1; i < rowCount; i++) { Vector2D abi = a + (ab * ((float)i / rowCount)); Vector2D dci = d + (ab * ((float)i / rowCount)); drawLine(new LineSegment2DF(abi, dci), PalmImageState.palmGrid); } } } }