当前位置: 首页>>代码示例>>C#>>正文


C# Skeleton.Where方法代码示例

本文整理汇总了C#中Microsoft.Kinect.Skeleton.Where方法的典型用法代码示例。如果您正苦于以下问题:C# Skeleton.Where方法的具体用法?C# Skeleton.Where怎么用?C# Skeleton.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Kinect.Skeleton的用法示例。


在下文中一共展示了Skeleton.Where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSkeletonForPlayer

        private Skeleton GetSkeletonForPlayer(int player)
        {
            Skeleton[] skeletons;

            using (SkeletonFrame skeletonFrame = this._skeletonFrameEventArgs.OpenSkeletonFrame())
            {
                if (skeletonFrame == null)
                {
                    throw new SkeletonFrameDataNotAvailableException();
                }

                skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                skeletonFrame.CopySkeletonDataTo(skeletons);
            }

            var tracked = skeletons
                .Where(skeleton => skeleton.TrackingState == SkeletonTrackingState.Tracked);

            if (!tracked.Any())
            {
                throw new Exception("No players found!");
            }

            return tracked.ElementAtOrDefault(player);
        }
开发者ID:swege,项目名称:KinectMouseControl,代码行数:25,代码来源:SkeletonHelper.cs

示例2: ObterEsqueletoUsuario

        public static Skeleton ObterEsqueletoUsuario(this SkeletonFrame quadro)
        {
            Skeleton esqueletoUsuario = null;
            Skeleton[] esqueletos = new Skeleton[quadro.SkeletonArrayLength];
            quadro.CopySkeletonDataTo(esqueletos);
            IEnumerable<Skeleton> esqueletosRastreados = esqueletos.Where(esqueleto => esqueleto.TrackingState == SkeletonTrackingState.Tracked);
            if (esqueletosRastreados.Count() > 0)
                esqueletoUsuario = esqueletosRastreados.First();

            return esqueletoUsuario;
        }
开发者ID:gilgaljunior,项目名称:CrieAplicacoesInterativascomoMicrosoftKinect,代码行数:11,代码来源:Extensao.cs

示例3: Main

        static void Main(string[] args)
        {
            var sensor = Microsoft.Kinect.KinectSensor.KinectSensors.FirstOrDefault(sens => sens.Status == KinectStatus.Connected);
            if (sensor == null)
                return;
            sensor.SkeletonStream.Enable();
            var skeletonData = new Skeleton[sensor.SkeletonStream.FrameSkeletonArrayLength];
            sensor.SkeletonFrameReady += (o, arg) =>
            {
                using (SkeletonFrame frame = arg.OpenSkeletonFrame())
                {
                    if (frame == null || skeletonData == null)
                        return;
                    frame.CopySkeletonDataTo(skeletonData);
                    foreach (var skeleton in skeletonData)
                    {

                    }
                }
            };
            sensor.Start();
            sensor.ElevationAngle = 0;
            sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Default;

            Vector<double> p0 = null, p1 = null, p2 = null;
            Func<Vector<double>, Vector<double>> transform = null;
            Func<Vector<double>> readRightHand = () => skeletonData.Where(row => row.TrackingState == SkeletonTrackingState.Tracked).Select(row => row.Joints[JointType.HandRight]).Select(row => new DenseVector(new double[] { row.Position.X, row.Position.Y, row.Position.Z })).FirstOrDefault();
            while (true)
            {
                var key = Console.ReadKey();
                if (key.Key == ConsoleKey.D0)
                    p0 = readRightHand();
                if (key.Key == ConsoleKey.D1)
                    p1 = readRightHand();
                if (key.Key == ConsoleKey.D2)
                    p2 = readRightHand();
                if (p0 != null && p1 != null && p2 != null)
                {
                    transform = WorldTransform.GenerateTransform(p0, p1, p2);
                }
                if (transform != null)
                {
                    var transformed = transform(readRightHand());
                    Console.Clear();
                    Console.WriteLine("Transformed: " + PosToString(transformed));
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("Untransformed: " + PosToString(readRightHand()));
                }
            }
        }
开发者ID:virrkharia,项目名称:dynamight,代码行数:53,代码来源:KinectApp.cs

示例4: DrawSkeleton

 /// <summary>
 /// Creates skeleton models for each of the tracked skeleton in the array
 /// </summary>
 /// <param name="skeletons">Array of all found skeletons</param>
 /// <param name="brush">Color of the skeleton</param>
 /// <param name="sensor">The sensor.</param>
 /// <param name="width">The width of the canvas.</param>
 /// <param name="height">The height of the canvas.</param>
 public void DrawSkeleton(Skeleton[] skeletons, Brush brush, KinectSensor sensor, double width, double height)
 {
     var skeletonModels = new ObservableCollection<Polyline>();
     foreach (var skeleton in skeletons.Where(skeleton => skeleton.TrackingState != SkeletonTrackingState.NotTracked))
     {
         skeletonModels.Add(CreateFigure(skeleton, brush, CreateBody(), sensor, width, height));
         skeletonModels.Add(CreateFigure(skeleton, brush, CreateLeftHand(), sensor, width, height));
         skeletonModels.Add(CreateFigure(skeleton, brush, CreateRightHand(), sensor, width, height));
         skeletonModels.Add(CreateFigure(skeleton, brush, CreateLeftLeg(), sensor, width, height));
         skeletonModels.Add(CreateFigure(skeleton, brush, CreateRightLeg(), sensor, width, height));
     }
     SkeletonParts = skeletonModels;
 }
开发者ID:blackViking007,项目名称:3D_Virtual_Fitting_Room,代码行数:21,代码来源:SkeletonManager.cs

示例5: onSkeletonFrameReady

        protected void onSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame != null)
                {
                    Skeleton[] squelettes = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    skeletonFrame.CopySkeletonDataTo(squelettes);

                    if (canvas.Children.Count > 2)
                        canvas.Children.RemoveRange(1, canvas.Children.Count - 1);

                    foreach (Skeleton squelette in squelettes.Where(skel => skel.TrackingState == SkeletonTrackingState.Tracked))
                    {
                        drawBone(squelette, canvas, JointType.Head, JointType.ShoulderCenter, Brushes.AliceBlue);

                        drawBone(squelette, canvas, JointType.ShoulderCenter, JointType.ShoulderLeft, Brushes.AliceBlue);
                        drawBone(squelette, canvas, JointType.ShoulderCenter, JointType.ShoulderRight, Brushes.AliceBlue);

                        drawBone(squelette, canvas, JointType.ShoulderCenter, JointType.Spine, Brushes.AliceBlue);

                        drawBone(squelette, canvas, JointType.Spine, JointType.HipCenter, Brushes.AliceBlue);

                        drawBone(squelette, canvas, JointType.HipCenter, JointType.HipLeft, Brushes.AliceBlue);
                        drawBone(squelette, canvas, JointType.HipCenter, JointType.HipRight, Brushes.AliceBlue);

                        drawBone(squelette, canvas, JointType.ShoulderLeft, JointType.ElbowLeft, Brushes.AliceBlue);
                        drawBone(squelette, canvas, JointType.ElbowLeft, JointType.WristLeft, Brushes.AliceBlue);
                        drawBone(squelette, canvas, JointType.WristLeft, JointType.HandLeft, Brushes.AliceBlue);

                        drawBone(squelette, canvas, JointType.ShoulderRight, JointType.ElbowRight, Brushes.AliceBlue);
                        drawBone(squelette, canvas, JointType.ElbowRight, JointType.WristRight, Brushes.AliceBlue);
                        drawBone(squelette, canvas, JointType.WristRight, JointType.HandRight, Brushes.AliceBlue);

                        // Left Leg
                        this.drawBone(squelette, canvas, JointType.HipLeft, JointType.KneeLeft, Brushes.AliceBlue);
                        this.drawBone(squelette, canvas, JointType.KneeLeft, JointType.AnkleLeft, Brushes.AliceBlue);
                        this.drawBone(squelette, canvas, JointType.AnkleLeft, JointType.FootLeft, Brushes.AliceBlue);

                        // Right Leg
                        this.drawBone(squelette, canvas, JointType.HipRight, JointType.KneeRight, Brushes.AliceBlue);
                        this.drawBone(squelette, canvas, JointType.KneeRight, JointType.AnkleRight, Brushes.AliceBlue);
                        this.drawBone(squelette, canvas, JointType.AnkleRight, JointType.FootRight, Brushes.AliceBlue);
                    }
                }
            }
        }
开发者ID:Karalix,项目名称:tp1kinect,代码行数:47,代码来源:SkeletonStream.cs

示例6: DesenharEsqueletoUsuario

        private void DesenharEsqueletoUsuario(SkeletonFrame quadro)
        {
            if (quadro == null) return;

            using (quadro)
            {
                Skeleton[] esqueletos = new Skeleton[quadro.SkeletonArrayLength];
                quadro.CopySkeletonDataTo(esqueletos);
                IEnumerable<Skeleton> esqueletosRastreados = esqueletos.Where(esqueleto => esqueleto.TrackingState == SkeletonTrackingState.Tracked);
                if (esqueletosRastreados.Count() > 0)
                {
                    Skeleton esqueleto = esqueletosRastreados.First();
                    EsqueletoUsuarioAuxiliar funcoesEsqueletos = new EsqueletoUsuarioAuxiliar(kinect);
                    funcoesEsqueletos.DesenharArticulacao(esqueleto.Joints[JointType.HandRight], canvasKinect);
                    funcoesEsqueletos.DesenharArticulacao(esqueleto.Joints[JointType.HandLeft], canvasKinect);
                }
            }
        }
开发者ID:gilgaljunior,项目名称:CrieAplicacoesInterativascomoMicrosoftKinect,代码行数:18,代码来源:MainWindow.xaml.cs

示例7: SensorSkeletonFrameReady

        // Process the new skeleton data
        private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {

            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame != null)
                {
                    // Copy the skeleton data to the "skeletons" array.
                    skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    skeletonFrame.CopySkeletonDataTo(skeletons);

                    // Cull off the non tracked skeletons.
                    skeletons = skeletons.Where(x => x.TrackingState == SkeletonTrackingState.Tracked).ToArray();

                    // Detect high fives between pairs of skeletons.
                    detectHighFives(skeletons);
                }
            }
        }
开发者ID:kyels,项目名称:KinectwithDora,代码行数:20,代码来源:Tutorial3Tasks.cs

示例8: Sensor_SkeletonFrameReady

        static void Sensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            using (var frame = e.OpenSkeletonFrame())
            {
                if (frame != null)
                {
                    Skeleton[] skeletons = new Skeleton[frame.SkeletonArrayLength];

                    frame.CopySkeletonDataTo(skeletons);

                    if (skeletons.Length > 0)
                    {
                        var user = skeletons.Where(u => u.TrackingState == SkeletonTrackingState.Tracked).FirstOrDefault();

                        if (user != null)
                        {
                            //_gesture.Update(user);
                        }
                    }
                }
            }
        }
开发者ID:jhaider,项目名称:we-know-that-feel,代码行数:22,代码来源:Program.cs

示例9: FindClosestSkeleton

        private Skeleton FindClosestSkeleton(Skeleton[] skeletons)
        {
            var seed = new
            {
                Distance = float.PositiveInfinity,
                Skeleton = new Skeleton()
            };

            var result = skeletons.Where(skeleton => skeleton.TrackingState != SkeletonTrackingState.NotTracked)
                .Aggregate(seed, (running, cur) =>
            {
                if (cur.Position.Z >= running.Distance)
                    return running;

                return new
                {
                    Distance = cur.Position.Z,
                    Skeleton = cur
                };
            });

            return result.Skeleton;
        }
开发者ID:techx,项目名称:old-techfair-kinect-booth,代码行数:23,代码来源:KinectSensorWrapper.cs

示例10: SkeletonFramesReady

        private static void SkeletonFramesReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            using (SkeletonFrame skeletonFrameData = e.OpenSkeletonFrame())
            {
                if (skeletonFrameData != null)
                {
                    var allSkeletons = new Skeleton[skeletonFrameData.SkeletonArrayLength];

                    skeletonFrameData.CopySkeletonDataTo(allSkeletons);

                    List<Skeleton> tracked =
                        allSkeletons.Where(s => s.TrackingState == SkeletonTrackingState.Tracked).ToList();
                    if (tracked.Any())
                    {
                        // Find the closest skeleton
                        Skeleton closest = tracked.OrderBy(t => t.Position.Z).First();

                        // Get the head x position
                        float headX = closest.Joints
                            .Where(j => j.JointType == JointType.Head)
                            .Select(h => h.Position.X)
                            .FirstOrDefault();

                        // Broadcast to subject
                        HeadXSubject.OnNext(headX);
                    }
                }
            }
        }
开发者ID:taylorgibb,项目名称:kinect-breaker,代码行数:29,代码来源:Program.cs

示例11: ExtractValidSkeletons

        private void ExtractValidSkeletons(Skeleton[] rawSkeletons)
        {
            var validSkeletons = rawSkeletons.Where(
            skeleton => skeleton.TrackingState == SkeletonTrackingState.Tracked &&
            skeleton.Joints.Count(joint => joint.TrackingState == JointTrackingState.Tracked) > Constants.MINIMUM_JOINT_THRESHOLD
              );

              foreach (Skeleton skeleton in validSkeletons)
              {
            if (currentVisitors.ContainsKey(skeleton.TrackingId))
              currentVisitors[skeleton.TrackingId].Update(skeleton);
            else
              currentVisitors.Add(skeleton.TrackingId, new WagSkeleton(skeleton));

            WagFaceTracker wagFaceTracker = wagFaceTrackers.SingleOrDefault(tracker => tracker.SkeletonId == skeleton.TrackingId);
            if (wagFaceTracker == null)
            {
              wagFaceTracker = wagFaceTrackers.FirstOrDefault(tracker => tracker.IsUsing == false);
              wagFaceTracker.SkeletonId = skeleton.TrackingId;
              wagFaceTracker.IsUsing = true;
            }

            currentVisitors[skeleton.TrackingId].LastFrameSeen = currentFrame;

            Calibration.ApplyTransformations(currentVisitors[skeleton.TrackingId]);
              }

              foreach (WagSkeleton wagSkeleton in currentVisitors.Values)
              {
            wagSkeleton.FramesNotSeen = currentFrame - wagSkeleton.LastFrameSeen;
              }

              OnPropertyChanged("ClosestVisitor");
        }
开发者ID:hcilab-um,项目名称:STim,代码行数:34,代码来源:Core.cs

示例12: SkeletonDataReadyHandler

 private void SkeletonDataReadyHandler(object sender, SkeletonFrameReadyEventArgs e)
 {
     // no active user, ignore events
     if (_activeUser == -1 || e == null || _kinect == null) return;
     // not recording and no context, ignore events.
     var sFrame = e.OpenSkeletonFrame();
     if (sFrame == null) return;
     var skeletons = new Skeleton[_kinect.GetSensor().SkeletonStream.FrameSkeletonArrayLength];
     sFrame.CopySkeletonDataTo(skeletons);
     sFrame.Dispose();
     foreach (var skeleton in skeletons.Where(skeleton => skeleton != null && skeleton.TrackingId == _activeUser))
     {
         Skeleton2DDataExtract.ProcessData(skeleton, _defaultHand);
         if (!_isRecording)
             if (_pointer != null) _pointer.FindContext(skeleton);
         if (_addOnGesture)
         {
             AddOnGesture(_addOnGestureType, skeleton);
         }
     }
 }
开发者ID:sepiroth887,项目名称:KinectHomer,代码行数:21,代码来源:GestureProcessor.cs

示例13: GetPrimarySkeleton

        /// <summary>
        /// Looks for the closest skeleton
        /// </summary>
        /// <param name="skeletons">All skeletons recognised by Kinect</param>
        /// <returns>The skeleton closestto the sensor</returns>
        public static Skeleton GetPrimarySkeleton(Skeleton[] skeletons)
        {
            Skeleton skeleton = null;

            if (skeletons != null)
                foreach (Skeleton skelet in skeletons.Where(s => s.TrackingState == SkeletonTrackingState.Tracked))
                    if (skeleton == null || skelet.Position.Z < skeleton.Position.Z)
                        skeleton = skelet;

            return skeleton;
        }
开发者ID:blackViking007,项目名称:3D_Virtual_Fitting_Room,代码行数:16,代码来源:KinectService.cs

示例14: NewSensor_SkeletonFrameReady

        void NewSensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs args)
        {
            var colors = new Dictionary<int, Color>();
            Skeleton[] skeletons;

            using (var frame = args.OpenSkeletonFrame())
            {
                if (frame == null)
                    return;

                skeletons = new Skeleton[frame.SkeletonArrayLength];
                frame.CopySkeletonDataTo(skeletons);
            }

            foreach (var skeleton in skeletons.Where(s => SkeletonTrackingState.Tracked.Equals(s.TrackingState)))
            {
                Random _rnd = new Random();
                var userId = skeleton.TrackingId;

                var crazyColors = Color.FromRgb((byte)_rnd.Next(255), (byte)_rnd.Next(255), (byte)_rnd.Next(255));

                colors.Add(userId, KinectRegion.PrimaryUserTrackingId == userId ?
                    crazyColors :
                    Colors.Blue);
            }

            this.KinectUserViewer.UserColors = colors;
        }
开发者ID:jorgeLuizChaves,项目名称:K4W,代码行数:28,代码来源:KinectInteractionsConfig.cs

示例15: SensorSkeletonFrameReady

        private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            Skeleton[] skeletons = new Skeleton[0];

            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame != null)
                {
                    skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    skeletonFrame.CopySkeletonDataTo(skeletons);
                    if (skeletons.Length > 0)
                    {
                        var user = skeletons.Where(u => u.TrackingState == SkeletonTrackingState.Tracked).FirstOrDefault();

                        if (user != null)
                        {
                            _gestureRight.Update(user);
                            _gestureLeft.Update(user);
                        }
                    }
                }
            }
        }
开发者ID:florian-bellotti,项目名称:REDX,代码行数:23,代码来源:FormDiffusion.cs


注:本文中的Microsoft.Kinect.Skeleton.Where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。