Ejemplo n.º 1
0
        private IList <FingerPoint> MapFingerPoints(IList <FingerPoint> oldFingerPoints, IList <FingerPoint> newFingerPoints)
        {
            var idGenerator = new IdGenerator();
            var distanceMap = new DistanceMap <FingerPoint, FingerPoint>(oldFingerPoints);

            distanceMap.Map(newFingerPoints);
            foreach (var tuple in distanceMap.MappedItems)
            {
                idGenerator.SetUsed(tuple.Item1.Id);
                tuple.Item2.Id         = tuple.Item1.Id;
                tuple.Item2.FrameCount = tuple.Item1.FrameCount + 1;
            }
            foreach (var newFinger in distanceMap.UnmappedItems)
            {
                newFinger.Id = idGenerator.GetNextId();
            }
            foreach (var discontinuedFinger in distanceMap.DiscontinuedItems)
            {
                discontinuedFinger.NegativeFrameCount++;
            }
            return(distanceMap.MappedItems.Select(i => i.Item2).Union(distanceMap.UnmappedItems).Union(distanceMap.DiscontinuedItems).Where(i => i.NegativeFrameCount <= this.settings.FramesForDiscontinuedFingerPoint).ToList());
        }
Ejemplo n.º 2
0
        private HandCollection CreateHandCollection(ShapeCollection shapes)
        {
            var map = new DistanceMap <HandData, Shape>(currentValue.Hands);

            map.Map(shapes.Shapes);

            var handData = new List <HandData>();

            foreach (var tupple in map.MappedItems)
            {
                handData.Add(this.Create(tupple.Item1, tupple.Item2));
            }
            foreach (var shape in map.UnmappedItems)
            {
                handData.Add(this.Create(shape));
            }
            foreach (var discontinuedHandData in map.DiscontinuedItems)
            {
                this.ReturnIdToPool(discontinuedHandData.Id);
            }

            return(new HandCollection(handData));
        }