using BBIWARG.Input.InputHandling; using BBIWARG.Recognition.Tracking; using BBIWARG.Utility; namespace BBIWARG.Recognition.HandRecognition { /// /// Keeps track of hands over a period of time. /// internal class HandTracker : Tracker { /// /// Initializes a new instance of the HandTracker class. /// /// Size of the input image. public HandTracker(ImageSize imageSize) : base(imageSize) { } /// /// Calculates the similarity [0-1] of a tracked Hand and a detected Hand. /// /// the tracked hand /// the detected hand /// the similarity public override float calculateSimilarity(TrackedHand trackedHand, Hand detectedHand) { return getPositionSimilarity(trackedHand.CentroidPrediction, detectedHand.Centroid, Parameters.HandTrackerMaxCentroidRelativeMove); } /// /// 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); } /// /// Creates a TrackedHand. /// /// the detected hand /// a tracked hand protected override TrackedHand createTrackedObject(Hand detectedObject) { return new TrackedHand(idPool.getNextUnusedID(), detectedObject, Parameters.HandTrackerNumFramesDetectedUntilTracked, Parameters.HandTrackerNumFramesLostUntilDeleted); } } }