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 { /// /// Keeps track of hands over a period of time. /// class HandTracker : Tracker { /// /// Initializes a new instance of the HandTracker class. /// /// Size of the input image. public HandTracker(ImageSize imageSize) : base(imageSize) { } /// /// Updates the TrackedHands with the detected hands in the current frame and stores the results in frameData.trackedFingers. /// /// the current frame public void trackHands(FrameData frameData) { trackObjects(frameData.DetectedHands); frameData.TrackedHands = getCurrentObjectsWithState(TrackingState.Tracked); } /// /// Calculates the similarity [0-1] of a tracked Hand and a detected Hand. /// /// the tracked hand /// the detected hand /// public override float calculateSimilarity(TrackedHand trackedHand, Hand detectedHand) { return getPositionSimilarity(trackedHand.CentroidPrediction, detectedHand.Centroid, Parameters.HandTrackerMaxCentroidRelativeMove); } /// /// Creates a TrackedHand. /// /// the detected hand /// a Trackedhand protected override TrackedHand createTrackedObject(Hand detectedObject) { return new TrackedHand(idPool.getNextUnusedID(), detectedObject, Parameters.HandTrackerNumFramesDetectedUntilTracked, Parameters.HandTrackerNumFramesLostUntilDeleted); } } }