HandTracker.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using bbiwarg.Recognition.Tracking;
  7. using bbiwarg.Input.InputHandling;
  8. using bbiwarg.Utility;
  9. namespace bbiwarg.Recognition.HandRecognition
  10. {
  11. class HandTracker : Tracker<Hand, TrackedHand>
  12. {
  13. public HandTracker(ImageSize imageSize)
  14. : base(imageSize)
  15. {
  16. }
  17. public void trackHands(FrameData frameData)
  18. {
  19. trackObjects(frameData.DetectedHands);
  20. frameData.TrackedHands = getCurrentObjectsWithState(TrackingState.Tracked);
  21. }
  22. public override float calculateSimilarity(TrackedHand trackedHand, Hand detectedHand)
  23. {
  24. return getPositionSimilarity(trackedHand.CentroidPrediction, detectedHand.Centroid, Parameters.HandTrackerMaxCentroidRelativeMove);
  25. }
  26. protected override TrackedHand createTrackedObject(Hand detectedObject)
  27. {
  28. return new TrackedHand(idPool.getNextUnusedID(), detectedObject, Parameters.HandTrackerNumFramesDetectedUntilTracked, Parameters.HandTrackerNumFramesLostUntilDeleted);
  29. }
  30. }
  31. }