Ejemplo n.º 1
0
        private FeJoint AddNewOrGet_JointByCoordinate(Point3d inPoint)
        {
            // Rounds the point coordinates
            inPoint = RoundedPoint3d(inPoint);

            // Already exists in the list?
            if (Joints.Any(a => a.Value.Point == inPoint))
            {
                return(Joints.First(a => a.Value.Point == inPoint).Value);
            }

            FeJoint newJoint = new FeJoint(_pointCount.ToString(), inPoint);

            Joints.Add(newJoint.Id, newJoint);
            _pointCount++;
            return(newJoint);
        }
Ejemplo n.º 2
0
Archivo: Kinect.cs Proyecto: hnjm/dron
        private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            var skeletons = new Skeleton[0];

            using (var skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame != null)
                {
                    skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    skeletonFrame.CopySkeletonDataTo(skeletons);
                }
            }
            foreach (var skeleton in skeletons)
            {
                Joints            = skeleton.Joints;
                IsSkeletonTracked = skeleton.TrackingState == SkeletonTrackingState.Tracked;
                SkeletonTracked?.Invoke(IsSkeletonTracked, new EventArgs());
                var trackedJoints = Joints
                                    .Where(x => x.TrackingState == JointTrackingState.Tracked)
                                    .Select(x => $"{x.JointType.ToString()} X:{x.Position.X.ToString("F2")} Y:{x.Position.Y.ToString("F2")} Z:{x.Position.Z.ToString("F2")}")
                                    .ToList();
                if (Joints[JointType.HandLeft].Position.Y < Joints[JointType.HipLeft].Position.Y &&
                    Joints[JointType.HandRight].Position.Y < Joints[JointType.HipRight].Position.Y || !Joints.Any(x => x.Position.Z > 0))
                {
                    return;
                }

                if (Joints[JointType.HandRight].Position.Y > Joints[JointType.Spine].Position.Y &&
                    Joints[JointType.HandLeft].Position.Y > Joints[JointType.Spine].Position.Y &&
                    Joints[JointType.ElbowLeft].Position.Y < Joints[JointType.Spine].Position.Y &&
                    Joints[JointType.ElbowRight].Position.Y < Joints[JointType.Spine].Position.Y)
                {
                    S = true;
                }

                if (Joints[JointType.HandRight].Position.Y > Joints[JointType.ShoulderCenter].Position.Y &&
                    Joints[JointType.HandLeft].Position.Y > Joints[JointType.ShoulderCenter].Position.Y &&
                    Joints[JointType.ElbowLeft].Position.Y < Joints[JointType.ShoulderCenter].Position.Y &&
                    Joints[JointType.ElbowRight].Position.Y < Joints[JointType.ShoulderCenter].Position.Y)
                {
                    W = true;
                }

                if (Joints[JointType.HandRight].Position.Y > Joints[JointType.ShoulderCenter].Position.Y &&
                    Joints[JointType.ElbowRight].Position.Y > Joints[JointType.ShoulderCenter].Position.Y &&
                    Joints[JointType.HandRight].Position.Y > Joints[JointType.Head].Position.Y &&
                    Joints[JointType.HandLeft].Position.Y < Joints[JointType.Spine].Position.Y)
                {
                    Up = true;
                }

                if (Joints[JointType.HandLeft].Position.Y > Joints[JointType.ShoulderCenter].Position.Y &&
                    Joints[JointType.ElbowLeft].Position.Y > Joints[JointType.ShoulderCenter].Position.Y &&
                    Joints[JointType.HandLeft].Position.Y > Joints[JointType.Head].Position.Y &&
                    Joints[JointType.HandRight].Position.Y < Joints[JointType.Spine].Position.Y)
                {
                    Down = true;
                }

                if (Joints[JointType.HandLeft].Position.X > Joints[JointType.HipCenter].Position.X)
                {
                    Right = true;
                }
                if (Joints[JointType.HandRight].Position.X < Joints[JointType.HipCenter].Position.X)
                {
                    Left = true;
                }

                if (Joints[JointType.HandLeft].Position.Y > Joints[JointType.Spine].Position.Y &&
                    Joints[JointType.ElbowLeft].Position.Y > Joints[JointType.Spine].Position.Y &&
                    Joints[JointType.HandLeft].Position.Y < Joints[JointType.Head].Position.Y &&
                    Joints[JointType.ElbowLeft].Position.Y < Joints[JointType.Head].Position.Y &&
                    Joints[JointType.HandRight].Position.Y < Joints[JointType.Spine].Position.Y)
                {
                    A = true;
                }
            }
        }