12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- 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 numRows = 4;
- int numColumns = 3;
- Vector2D relAB = (b - a) / numRows;
- Vector2D relDC = (c - d) / numRows;
- Vector2D relBC = (c - b) / numColumns;
- Vector2D relAD = (d - a) / numColumns;
- for (int i = 1; i < numRows; i++)
- {
- drawLine(new Emgu.CV.Structure.LineSegment2DF(a + i * relAB, d + i * relDC), PalmImageState.palmGrid);
- }
- for (int i = 1; i < numColumns; i++)
- {
- drawLine(new Emgu.CV.Structure.LineSegment2DF(a + i * relAD, b + i * relBC), PalmImageState.palmGrid);
- }
- }
- }
- }
|