12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- 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.PalmRecognition
- {
- class PalmTracker : Tracker<Palm, TrackedPalm>
- {
- public PalmTracker(ImageSize imageSize)
- : base(imageSize)
- {
- }
- public void trackPalms(FrameData frameData)
- {
- trackObjects(frameData.DetectedPalms);
- frameData.TrackedPalms = getOptimizedPalms();
- }
- public override float calculateSimilarity(TrackedPalm trackedPalm, Palm detectedPalm)
- {
- float handSimilarity = (detectedPalm.Hand.TrackID == trackedPalm.LastObject.Hand.TrackID) ? 1 : 0;
- float wristUpperSimilarity = getPositionSimilarity(trackedPalm.WristUpperPrediction, detectedPalm.WristUpper, Parameters.PalmTrackerMaxWristUpperRelativeMove);
- float wristLowerSimilarity = getPositionSimilarity(trackedPalm.WristLowerPrediction, detectedPalm.WristLower, Parameters.PalmTrackerMaxWristLowerRelativeMove);
- float fingersUpperSimilarity = getPositionSimilarity(trackedPalm.FingersUpperPrediction, detectedPalm.FingersUpper, Parameters.PalmTrackerMaxFingersUpperRelativeMove);
- float fingersLowerSimilarity = getPositionSimilarity(trackedPalm.FingersLowerPrediction, detectedPalm.FingersLower, Parameters.PalmTrackerMaxFingersLowerRelativeMove);
- return handSimilarity * wristUpperSimilarity * wristLowerSimilarity * fingersUpperSimilarity * fingersLowerSimilarity;
- }
- protected override TrackedPalm createTrackedObject(Palm detectedPalm)
- {
- return new TrackedPalm(idPool.getNextUnusedID(), detectedPalm, Parameters.PalmTrackerNumFramesDetectedUntilTracked, Parameters.PalmTrackerNumFramesLostUntilDeleted);
- }
- private List<Palm> getOptimizedPalms()
- {
- List<Palm> optimizedPalms = new List<Palm>();
- foreach (TrackedPalm tp in TrackedObjects)
- {
- if (tp.CurrentState == TrackingState.Tracked)
- optimizedPalms.Add(tp.OptimizedPalm);
- }
- return optimizedPalms;
- }
- }
- }
|