Finger.cs 2.6 KB

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