123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using bbiwarg.Recognition.Tracking;
- using bbiwarg.Input.InputHandling;
- using bbiwarg.Utility;
- namespace bbiwarg.Recognition.HandRecognition
- {
- /// <summary>
- /// Keeps track of hands over a period of time.
- /// </summary>
- class HandTracker : Tracker<Hand, TrackedHand>
- {
- /// <summary>
- /// Initializes a new instance of the HandTracker class.
- /// </summary>
- /// <param name="imageSize">Size of the input image.</param>
- public HandTracker(ImageSize imageSize)
- : base(imageSize)
- {
- }
- /// <summary>
- /// Updates the TrackedHands with the detected hands in the current frame and stores the results in frameData.trackedFingers.
- /// </summary>
- /// <param name="frameData">the current frame</param>
- public void trackHands(FrameData frameData)
- {
- trackObjects(frameData.DetectedHands);
- frameData.TrackedHands = getCurrentObjectsWithState(TrackingState.Tracked);
- }
- /// <summary>
- /// Calculates the similarity [0-1] of a tracked Hand and a detected Hand.
- /// </summary>
- /// <param name="trackedHand">the tracked hand</param>
- /// <param name="detectedHand">the detected hand</param>
- /// <returns>the similarity</returns>
- public override float calculateSimilarity(TrackedHand trackedHand, Hand detectedHand)
- {
- return getPositionSimilarity(trackedHand.CentroidPrediction, detectedHand.Centroid, Parameters.HandTrackerMaxCentroidRelativeMove);
- }
- /// <summary>
- /// Creates a TrackedHand.
- /// </summary>
- /// <param name="detectedObject">the detected hand</param>
- /// <returns>a Trackedhand</returns>
- protected override TrackedHand createTrackedObject(Hand detectedObject)
- {
- return new TrackedHand(idPool.getNextUnusedID(), detectedObject, Parameters.HandTrackerNumFramesDetectedUntilTracked, Parameters.HandTrackerNumFramesLostUntilDeleted);
- }
- }
- }
|