1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- 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<Gray, Byte> image;
- public PalmImage(int width, int height)
- {
- image = new Image<Gray, byte>(width, height);
- }
- public PalmImageState getStateAt(int x, int y)
- {
- return (PalmImageState)image.Data[y, x, 0];
- }
- public void drawContour(Contour<Point> 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);
- }
- }
- }
- }
|