Пример #1
0
 public HandData(int id, Shape shape, Palm palm, IList<FingerPoint> fingerPoints)
 {
     this.id = id;
     this.shape = shape;
     this.palm = palm;
     this.fingerPoints = fingerPoints;
 }
Пример #2
0
 public HandData(int id, Shape shape, Palm palm, IList <FingerPoint> fingerPoints)
 {
     this.id           = id;
     this.shape        = shape;
     this.palm         = palm;
     this.fingerPoints = fingerPoints;
 }
Пример #3
0
        private void FindCenterFromCandidates(IList <Point> contour, IList <Point> candidates)
        {
            double[] distances = new double[candidates.Count];

            Parallel.For(0, candidates.Count, (index) =>
            {
                distances[index] = FindMaxDistance(contour, candidates[index]);
            });

            double maxDistance = this.result == null ? 0 : this.result.DistanceToContour;
            int    maxIndex    = -1;

            for (int index = 0; index < distances.Length; index++)
            {
                if (distances[index] > maxDistance)
                {
                    maxDistance = distances[index];
                    maxIndex    = index;
                }
            }
            if (maxIndex >= 0)
            {
                this.result = new Palm(candidates[maxIndex], maxDistance);
            }
        }
Пример #4
0
 public Palm FindCenter(Contour contour, IList<Point> candidates)
 {
     this.result = null;
     var minimizedContour = new LineThinner(contourReduction, false).Filter(contour.Points);
     this.FindCenterFromCandidates(minimizedContour, candidates);
     this.IncreaseAccuracy(this.result.Location, minimizedContour);
     return result;
 }
Пример #5
0
 private double FindMaxDistance(IList<Point> contourPoints, Point candidate)
 {
     double result = double.MaxValue;
     foreach (var point in contourPoints)
     {
         result = Math.Min(Point.Distance(point.X, point.Y, candidate.X, candidate.Y), result);
     }
     return result;
 }
Пример #6
0
        public Palm FindCenter(Contour contour, IList <Point> candidates)
        {
            this.result = null;
            var minimizedContour = new LineThinner(contourReduction, false).Filter(contour.Points);

            this.FindCenterFromCandidates(minimizedContour, candidates);
            this.IncreaseAccuracy(this.result.Location, minimizedContour);
            return(result);
        }
Пример #7
0
        private double FindMaxDistance(IList <Point> contourPoints, Point candidate)
        {
            double result = double.MaxValue;

            foreach (var point in contourPoints)
            {
                result = Math.Min(Point.Distance(point.X, point.Y, candidate.X, candidate.Y), result);
            }
            return(result);
        }
Пример #8
0
        private Palm DetectPalm(Shape shape, Contour contour)
        {
            var  candidates = shape.Points;
            Palm palm       = null;

            if (this.settings.DetectCenterOfPalm && shape.PointCount > 0 && contour.Count > 0)
            {
                palm = this.palmFinder.FindCenter(contour, shape.Points);
            }
            return(palm);
        }
Пример #9
0
 public Palm FindCenter(ConvexHull hull, Contour contour, IList<Point> candidates)
 {
     this.result = null;
     candidates = ReduceCandidatePoints(hull, candidates);
     if (candidates.Count > 0)
     {
         var minimizedContour = new LineThinner(contourReduction, false).Filter(contour.Points);
         this.FindCenterFromCandidates(minimizedContour, candidates);
         if (this.result != null)
         {
             this.IncreaseAccuracy(this.result.Location, minimizedContour);
         }
     }
     return result;
 }
Пример #10
0
 public Palm FindCenter(ConvexHull hull, Contour contour, IList <Point> candidates)
 {
     this.result = null;
     candidates  = ReduceCandidatePoints(hull, candidates);
     if (candidates.Count > 0)
     {
         var minimizedContour = new LineThinner(contourReduction, false).Filter(contour.Points);
         this.FindCenterFromCandidates(minimizedContour, candidates);
         if (this.result != null)
         {
             this.IncreaseAccuracy(this.result.Location, minimizedContour);
         }
     }
     return(result);
 }
Пример #11
0
        private void FindCenterFromCandidates(IList<Point> contour, IList<Point> candidates)
        {
            double[] distances = new double[candidates.Count];

            Parallel.For(0, candidates.Count, (index) =>
            {
                distances[index] = FindMaxDistance(contour, candidates[index]);
            });

            double maxDistance = this.result == null ? 0 : this.result.DistanceToContour;
            int maxIndex = -1;
            for (int index = 0; index < distances.Length; index++)
            {
                if (distances[index] > maxDistance)
                {
                    maxDistance = distances[index];
                    maxIndex = index;
                }
            }
            if (maxIndex >= 0)
            {
                this.result = new Palm(candidates[maxIndex], maxDistance);
            }
        }
        public static void DetectarCentroPalma(IList<Point> contour, IList<PointF> candidates)
        {
            double[] distances = new double[candidates.Count];

            Parallel.For(0, candidates.Count, (index) =>
            {
                distances[index] = FindMaxDistance(contour, candidates[index]);
            });

            double maxDistance = result == null ? 0 : result.DistanceToContour;
            int maxIndex = -1;
            for (int index = 0; index < distances.Length; index++)
            {
                if (distances[index] > maxDistance)
                {
                    maxDistance = distances[index];
                    maxIndex = index;
                }
            }
            if (maxIndex >= 0)
            {
                result = new Palm(candidates[maxIndex], maxDistance);
            }
        }