using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using MathNet.Numerics.LinearAlgebra.Single; using bbiwarg.InputProviders; using bbiwarg.VideoHandles; using bbiwarg.Helpers; namespace bbiwarg.Detectors { class PalmDetection { private IInputProvider input; private VideoHandle videoHandle; private ForeFingerDetection foreFingerDetection; public PalmDetection(IInputProvider input, VideoHandle videoHandle) { this.input = input; this.videoHandle = videoHandle; this.foreFingerDetection = new ForeFingerDetection(input, videoHandle); } public Palm getPalm(uint handIndex) { DenseVector palmMiddle = (DenseVector) input.getPalmPosition3D(handIndex); DenseVector tipPosition = (DenseVector)input.getTipPosition3D(handIndex); DenseVector palmNormal = (DenseVector)input.getPalmNormal3D(handIndex); //DenseVector thumbPosition = (DenseVector) input.getFingerTipPositions3D(handIndex)[0]; //DenseVector palmToThumb_2 = (thumbPosition - palmMiddle) / 2.0f; DenseVector tipToForeFinger = tipPosition - palmMiddle; DenseVector palmToThumb_2 = (DenseVector) tipToForeFinger.Cross(palmNormal) / 3.0f; return new Palm(palmMiddle + palmToThumb_2 + tipToForeFinger, palmMiddle - palmToThumb_2 + tipToForeFinger, palmMiddle - palmToThumb_2 - tipToForeFinger / 2.0f, palmMiddle + palmToThumb_2 - tipToForeFinger / 2.0f); } } }