Finger.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using BBIWARG.Recognition.HandRecognition;
  2. using BBIWARG.Recognition.TouchRecognition;
  3. using BBIWARG.Recognition.Tracking;
  4. using BBIWARG.Utility;
  5. using Emgu.CV;
  6. using System.Drawing;
  7. namespace BBIWARG.Recognition.FingerRecognition
  8. {
  9. /// <summary>
  10. /// The Finger class represents a Finger.
  11. /// </summary>
  12. public class Finger : TrackableObject
  13. {
  14. /// <summary>
  15. /// the direction of the finger (end to start)
  16. /// </summary>
  17. public Vector2D Direction { get { return SliceTrail.FittedDirection; } }
  18. /// <summary>
  19. /// the hand the finger belongs to
  20. /// </summary>
  21. public Hand Hand { get; set; }
  22. /// <summary>
  23. /// the position of the finger end (hand)
  24. /// </summary>
  25. public Vector2D HandPoint { get { return SliceTrail.EndSlice.Mid; } }
  26. /// <summary>
  27. /// the line segment from start to end
  28. /// </summary>
  29. public LineSegment2D LineSegment { get { return SliceTrail.LineSegment; } }
  30. /// <summary>
  31. /// a position in the middle of the finger
  32. /// </summary>
  33. public Vector2D MidPoint { get { return SliceTrail.MidSlice.Mid; } }
  34. /// <summary>
  35. /// the finger slices
  36. /// </summary>
  37. public FingerSliceTrail SliceTrail { get; private set; }
  38. /// <summary>
  39. /// the position of the finger tip
  40. /// </summary>
  41. public Vector2D TipPoint { get { return SliceTrail.StartSlice.Mid; } }
  42. /// <summary>
  43. /// the touch of the current finger
  44. /// </summary>
  45. public Touch Touch { get; set; }
  46. /// <summary>
  47. /// Initializes a new instance of the Finger class.
  48. /// </summary>
  49. /// <param name="sliceTrail">The finger slice trail.</param>
  50. public Finger(FingerSliceTrail sliceTrail)
  51. : base()
  52. {
  53. SliceTrail = sliceTrail;
  54. }
  55. /// <summary>
  56. /// Gets a contour of the finger
  57. /// </summary>
  58. /// <param name="margin">the margin around the finger (distance in pixels)</param>
  59. /// <returns>the contour of the finger</returns>
  60. public Contour<Point> getContour(float margin)
  61. {
  62. return SliceTrail.getContour(margin);
  63. }
  64. /// <summary>
  65. /// Reverses the finger (start to end)
  66. /// </summary>
  67. public void reverse()
  68. {
  69. SliceTrail.reverse();
  70. }
  71. }
  72. }