using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using bbiwarg.Recognition.Tracking;
using bbiwarg.Input.InputHandling;

namespace bbiwarg.Recognition.PalmRecognition
{
    class PalmTracker : Tracker<Palm, TrackedPalm>
    {
        public void trackPalms(FrameData frameData) {
            trackObjects(frameData.DetectedPalms);
            frameData.TrackedPalms = getOptimizedPalms();
        }

        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;
        }
    }
}
