using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using bbiwarg.Recognition.HandRecognition; using bbiwarg.Utility; using Emgu.CV.Structure; using Emgu.CV; namespace bbiwarg.Recognition.PalmRecognition { class PalmDetector { private List hands; private List palmHands; public List Palms { get; private set; } public PalmDetector(List hands) { this.hands = hands; findPalmHands(); createPalms(); } private void findPalmHands() { palmHands = new List(); foreach (Hand hand in hands) { if (hand.ThumbDefect != null) palmHands.Add(hand); } } private void createPalms() { Palms = new List(); foreach (Hand palmHand in palmHands) { ConvexityDefect thumbDefect = palmHand.ThumbDefect; Vector2D handLength = 1.5f*thumbDefect.VectorLong; Vector2D handWidth = 0.45f*handLength.getOrthogonal(palmHand.Side == HandSide.Right); Vector2D fingersUpper = thumbDefect.Inner + 0.75f*handLength; Vector2D wristUpper = thumbDefect.Inner - 0.25f*handLength; Vector2D wristLower = wristUpper + handWidth; Vector2D fingersLower = wristLower + 0.75f * handLength - 0.2f * handWidth; Palm palm = new Palm(palmHand, wristUpper, wristLower, fingersLower, fingersUpper); Palms.Add(palm); palmHand.setPalm(palm); } } } }