12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using bbiwarg.Recognition.Tracking;
- using bbiwarg.Utility;
- using bbiwarg.Input.InputHandling;
- namespace bbiwarg.Recognition.FingerRecognition
- {
- class FingerTracker : Tracker<Finger, TrackedFinger>
- {
- public FingerTracker(ImageSize imageSize)
- : base(imageSize)
- {
- }
- public void trackFingers(FrameData frameData) {
- trackObjects(frameData.DetectedFingers);
- frameData.TrackedFingers = getCurrentObjectsWithState(TrackingState.Tracked);
- }
- public override float calculateSimilarity(TrackedFinger trackedFinger, Finger detectedFinger)
- {
- Vector2D tip, hand;
- if (trackedFinger.shouldFingerBeReversed(detectedFinger))
- {
- tip = detectedFinger.HandPoint;
- hand = detectedFinger.TipPoint;
- }
- else
- {
- tip = detectedFinger.TipPoint;
- hand = detectedFinger.HandPoint;
- }
- float tipPointSimilarity = getPositionSimilarity(trackedFinger.TipPointPrediction, tip, Parameters.FingerTrackerMaxTipPointRelativeMove);
- float handPointSimilarity = getPositionSimilarity(trackedFinger.HandPointPrediction, hand, Parameters.FingerTrackerMaxHandPointRelativeMove);
- return tipPointSimilarity * handPointSimilarity;
- }
- protected override TrackedFinger createTrackedObject(Finger detectedObject)
- {
- return new TrackedFinger(idPool.getNextUnusedID(), detectedObject, Parameters.FingerTrackerNumFramesDetectedUntilTracked, Parameters.FingerTrackerNumFramesLostUntilDeleted);
- }
- }
- }
|