Ejemplo n.º 1
0
        public static double getVectorAngle(List <double> p1, List <double> p2)
        {
            if (p1 == null || p2 == null)
            {
                throw new Exception("all points have to exist");
            }
            if (p1.Count != p2.Count)
            {
                throw new Exception("All points have to same space");
            }
            double dotProductPoint = KinectAngleBody.GetDotProduct(new List <List <double> >()
            {
                p1, p2
            });
            double productMagnitude = KinectAngleBody.GetMagnitude(p1, new List <double> {
                0, 0
            });

            productMagnitude *= KinectAngleBody.GetMagnitude(p2, new List <double> {
                0, 0
            });

            dotProductPoint /= productMagnitude;

            double radians = Math.Acos(dotProductPoint);

            return((radians * 180) / Math.PI);
        }
Ejemplo n.º 2
0
        public static double getAngleBody(Point origenPoint, Point p1, Point p2)
        {
            List <double> _origenPoint = new List <double> {
                origenPoint.X, origenPoint.Y
            };
            List <double> _p1 = new List <double> {
                p1.X, p1.Y
            };
            List <double> _p2 = new List <double> {
                p2.X, p2.Y
            };

            _p1 = KinectAngleBody.GetTraslationPoint(_origenPoint, _p1);
            _p2 = KinectAngleBody.GetTraslationPoint(_origenPoint, _p2);

            return(KinectAngleBody.getVectorAngle(_p1, _p2));
        }
        /// <summary>
        /// Constructor de la clase que inicializa todos los componentes
        /// </summary>
        /// <param name="kinectSensor">Instancia del sensor</param>
        public KinectBodyView(KinectSensor kinectSensor, HeaderView headerView)
        {
            // Validacion si el sensor esta conectado
            if (kinectSensor == null)
            {
                throw new ArgumentNullException("kinectSensor");
            }
            if (headerView == null)
            {
                throw new ArgumentNullException("headerview");
            }

            this.isCalibrate = false;
            this.HeaderView  = headerView;

            this.joinsAnalize = new Dictionary <JointType, DetailsOfStepFunctionalMovement>();
            getjoinsAnalize();

            // Obtiene los angulos de movimiento
            this.kinectAngleBody = new KinectAngleBody();

            // obtiene el mapeo del kinect
            this.coordinateMapper = kinectSensor.CoordinateMapper;

            // Obtiene la profundidad del kinect
            FrameDescription frameDescription = kinectSensor.DepthFrameSource.FrameDescription;

            // Obtiene el ancho y la altura que analiza el kinect
            this.displayWidth  = frameDescription.Width;
            this.displayHeight = frameDescription.Height;

            startBody();

            // Instancia de todo el cuerpo
            this.drawingGroup = new DrawingGroup();

            // Control de imagen
            this.imageSource = new DrawingImage(this.drawingGroup);
        }
Ejemplo n.º 4
0
        public void getAngle(List <int> _angles, int i)
        {
            List <List <StepFunctionalMovement> > _series = this.stepsByMovement[i];

            for (int x = 0; x < _series.Count; x++)
            {
                List <StepFunctionalMovement> _repetitions = _series[x];
                bool isOut = false;
                int  ii    = 0;
                foreach (StepFunctionalMovement step in _repetitions)
                {
                    if (step != null)
                    {
                        if (ii == 0)
                        {
                            step.time = 0;
                        }
                        else
                        {
                            step.time = _repetitions[ii].accumulate - _repetitions[ii - 1].accumulate;
                        }
                        foreach (int _angle in _angles)
                        {
                            List <JointType> joints = DetailsOfStepFunctionalMovement.translateAngles(_angle);
                            List <DetailsOfStepFunctionalMovement> vectorialPoints = step.detailsOfStepFunctionalMovement.FindAll(e => joints.Contains((JointType)e.join));
                            if (vectorialPoints.Count != 3)
                            {
                                isOut = true; break;
                            }
                            DetailsOfStepFunctionalMovement origen = vectorialPoints.Find(e => e.join == (int)joints[0]);
                            if (origen == null)
                            {
                                isOut = true;  break;
                            }
                            vectorialPoints.RemoveAll(e => (int)e.join == (int)joints[0]);
                            if (vectorialPoints.Count != 2)
                            {
                                isOut = true; break;
                            }
                            if ((vectorialPoints[0] == null) || (vectorialPoints[1] == null))
                            {
                                isOut = true; break;
                            }
                            Point po = new Point(origen.x, origen.y);
                            Point p1 = new Point(vectorialPoints[0].x, vectorialPoints[0].y);
                            Point p2 = new Point(vectorialPoints[1].x, vectorialPoints[1].y);
                            origen.angle = KinectAngleBody.getAngleBody(po, p1, p2);
                        }
                        Predicate <DetailsOfStepFunctionalMovement> predicate = detail => {
                            return(!_angles.Contains(detail.join));
                        };
                        step.detailsOfStepFunctionalMovement.RemoveAll(predicate);
                    }
                    else
                    {
                        isOut = true;
                    }
                    if (isOut == true)
                    {
                        break;
                    }
                    ii++;
                }
                if (isOut == true)
                {
                    _series.RemoveAt(x);
                    x--;
                }
            }
        }