/// <summary>
        /// A method to tune the hand detector.
        /// </summary>
        /// <param name="tuning">The <see cref="IHandsDetectorTuning"/> tuning object.</param>
        /// <returns>The neutral hands that was detected right after tuning.</returns>
        public NormalizedHands Tune(IHandsDetectorTuning tuning)
        {
            this.tuning = tuning;

            HandsDetectorResult result = this.DetectHandsInternally(this.tuning.HandsForeground);

            this.neutralHands = result.Hands;

            this.Tuned = true;

            return(this.neutralHands);
        }
        private HandsDetectorResult DetectHandsInternally(BgrImage image)
        {
            int handAreaWidth = image.Width / DIVISOR_TO_GET_HAND_AREA_WIDTH_FROM_IMAGE_WIDTH;

            NormalizedHand left  = this.EvaluatePixels(image, 0, handAreaWidth, this.tuning.HandsColorMaps.Left, this.neutralHands?.Left);
            NormalizedHand right = this.EvaluatePixels(image, image.Width - handAreaWidth, handAreaWidth, this.tuning.HandsColorMaps.Right, this.neutralHands?.Right);

            int radius = image.Width * image.Height / DIVISOR_TO_GET_HAND_MARKER_CIRCLE_RADIUS_FROM_IMAGE_SIZE;

            if (this.Tuned && this.neutralHands != null)
            {
                image.DrawLineSegment(left.X, left.Y, this.neutralHands.Center.X, this.neutralHands.Center.Y, Color.Yellow, radius);
                image.DrawLineSegment(this.neutralHands.Center.X, this.neutralHands.Center.Y, right.X, right.Y, Color.Yellow, radius);
            }

            image.DrawCircle(left.X, left.Y, Color.Blue, radius, BgrImage.FILL_DRAWING);
            image.DrawCircle(right.X, right.Y, Color.Blue, radius, BgrImage.FILL_DRAWING);

            NormalizedHands normalizedHands = new NormalizedHands(left, right);

            return(new HandsDetectorResult(normalizedHands, image));
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HandsDetectorResult"/> class.
 /// </summary>
 /// <param name="hands">The detected hands.</param>
 /// <param name="image">The image of the hand detection.</param>
 public HandsDetectorResult(NormalizedHands hands, BgrImage image)
 {
     this.Hands = hands;
     this.Image = image;
 }