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


C# SkeletonFrameReadyEventArgs.OpenSkeletonFrame方法代码示例

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


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

示例1: Nui_SkeletonFrameReady

        static void Nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) {

            
            //Skeleton[] skeletons;
            List<Skeleton> skeletons = new List<Skeleton>();
            bool receivedData = false;
            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) {
                if (skeletonFrame != null) {
                    if (skeletons == null) {
                        //skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                        var addskels = new Skeleton();
                        skeletons.Add(addskels);
                    }
                    receivedData = true;
                } else {
                    // apps processing of skeleton data took too long; it got more than 2 frames behind.
                    // thedata is no longer avabilable.
                }
                if (receivedData) {
                    string json = skeletons.Serialize();

                    //string json = skeletonFrame.CopySkeletonDataTo(

                    foreach (var socket in _sockets) {
                        SkeletonFrame allSkeletons = e.OpenSkeletonFrame();
                        Skeleton playerSkeleton = (from s in skeletons where s.TrackingState == SkeletonTrackingState.Tracked select s).FirstOrDefault();
                        Joint rightHandJoint = playerSkeleton.Joints[JointType.HandRight];
                        Console.WriteLine("working");
                        socket.Send(json);
                    }
                }

            }
        }
开发者ID:praneeth130,项目名称:wonderama,代码行数:34,代码来源:Program.cs

示例2: KinectSkeletonFrameReady

        /// <summary>
        /// The event handler for the SkeletonFrameReady event.
        /// Grabs the skeleton data, serializes it and sends it over the pipe to the server
        /// </summary>
        /// <param name="sender">The sending object</param>
        /// <param name="e">Contains the skeleton frame data</param>
        protected void KinectSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            if (skeletonData == null)
            {
                skeletonData = new Skeleton[e.OpenSkeletonFrame().SkeletonArrayLength];
            }

            SkeletonFrame frame = e.OpenSkeletonFrame();
            frame.CopySkeletonDataTo(skeletonData);
            frame.Dispose();

            this.SendSkeletonData();
        }
开发者ID:NUIC,项目名称:2-Kinects-1-Machine,代码行数:19,代码来源:KinectClient.cs

示例3: sensor_SkeletonFrameReady

        void sensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            //frameNumber = frameNumber + 1;
            timepassed++;
            seconds = timepassed / 30;

            e.OpenSkeletonFrame().CopySkeletonDataTo(skeletons);
            int counter = 0;
            foreach(Skeleton skeleton in skeletons)
            {
                if (skeleton.TrackingState == SkeletonTrackingState.Tracked)
                    counter++;
            }

            //Console.WriteLine("Frame: {0}, Number of Skeletons: {1}",  frameNumber, counter);
            if (timepassed == seconds * 30)
                Console.WriteLine("Seconds passed: {0}, Number of Skeletons: {1}", seconds, counter);

            if (counter > 0)
            {
                if (timepassed == seconds * 30)
                {
                    Console.WriteLine("Location of head: " + skeletons[counter].Joints[JointType.Head].Position.X + ", " + skeletons[counter].Joints[JointType.Head].Position.Y + ", " + skeletons[counter].Joints[JointType.Head].Position.Z + "; Found at: " + DateTime.Now);
                }
            }
        }
开发者ID:hcilab-um,项目名称:STim,代码行数:26,代码来源:Program.cs

示例4: kinectSensor_SkeletonFrameReady

        private void kinectSensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            using (SkeletonFrame frame = e.OpenSkeletonFrame())
            {
                if (frame == null)
                    return;

                frame.GetSkeletons(ref skeletons);

                if (skeletons.All(s => s.TrackingState == SkeletonTrackingState.NotTracked))
                    return;

                foreach (var skeleton in skeletons)
                {
                    if (skeleton.TrackingState != SkeletonTrackingState.Tracked)
                        continue;

                    foreach (Joint joint in skeleton.Joints)
                    {
                        if (joint.TrackingState != JointTrackingState.Tracked)
                            continue;

                        if (joint.JointType == JointType.HandRight)
                        {
                            MouseController.Current.SetHandPosition(kinectSensor, joint, skeleton);
                        }
                    }
                }
            }
        }
开发者ID:rajankz,项目名称:cmsc838f-a4,代码行数:30,代码来源:MainWindow.xaml.cs

示例5: KinectDevice_SkeletonFrameReady

        //---------------------METHODS-------------
        #region Methods
        private void KinectDevice_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            SkeletonsPanel.Children.Clear();
            JointInfoPanel.Children.Clear();

            if (this.IsEnabled)
            {
                using (SkeletonFrame frame = e.OpenSkeletonFrame())
                {
                    if (frame != null)
                    {
                        if (this.IsEnabled)
                        {
                            Brush brush;
                            Skeleton skeleton;
                            frame.CopySkeletonDataTo(this._FrameSkeletons);

                            for (int i = 0; i < this._FrameSkeletons.Length; i++)
                            {

                                skeleton = this._FrameSkeletons[i];
                                brush = this._SkeletonBrushes[i];
                                DrawSkeleton(skeleton, brush);

                                TrackJoint(skeleton.Joints[JointType.HandLeft], brush);
                                TrackJoint(skeleton.Joints[JointType.HandRight], brush);
                                //You can track all the joints if you want
                            }
                        }
                    }
                }
            }
        }
开发者ID:Kazhunter,项目名称:Kinect,代码行数:35,代码来源:SkeletonViewer.xaml.cs

示例6: Sensor_SkeletonFrameReady

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

                    frame.CopySkeletonDataTo(bodies);

                    var body = bodies.Where(b => b.TrackingState == SkeletonTrackingState.Tracked).FirstOrDefault();

                    if (body != null)
                    {
                        Joint handLeft = body.Joints[JointType.HandLeft];
                        Joint handRight = body.Joints[JointType.HandRight];

                        if (handLeft.TrackingState != JointTrackingState.NotTracked && handRight.TrackingState != JointTrackingState.NotTracked)
                        {
                            // Select the hand that is closer to the sensor.
                            var activeHand = handRight.Position.Z <= handLeft.Position.Z ? handRight : handLeft;
                            var position = _sensor.CoordinateMapper.MapSkeletonPointToColorPoint(activeHand.Position, ColorImageFormat.RgbResolution640x480Fps30);

                            cursor.Flip(activeHand);                            
                            cursor.Update(position);
                        }
                    }
                }
            }
        }
开发者ID:guozanhua,项目名称:kinect-controls,代码行数:30,代码来源:MainWindow.xaml.cs

示例7: MeasureAngle

 protected void MeasureAngle(object sender,SkeletonFrameReadyEventArgs e)
 {
     if(IsEnabled)
         using(SkeletonFrame skeletonFrame=e.OpenSkeletonFrame())
             if(skeletonFrame!=null){
                 Skeleton[] skeletons=new Skeleton[skeletonFrame.SkeletonArrayLength];
                 skeletonFrame.CopySkeletonDataTo(skeletons);
                 Skeleton firstTrackedSkeleton=null;
                 foreach(Skeleton skel in skeletons)
                     if(skel.TrackingState==SkeletonTrackingState.Tracked){
      								firstTrackedSkeleton=skel;
                         break;
                     }
                 if(firstTrackedSkeleton==null){
                     IsTracking=false;
                     return;
                 }
                 IsTracking=true;
                 var point1=sensor.CoordinateMapper.MapSkeletonPointToDepthPoint(firstTrackedSkeleton.Joints[JointType.HandRight].Position,DepthImageFormat.Resolution640x480Fps30);
                 var point2=sensor.CoordinateMapper.MapSkeletonPointToDepthPoint(firstTrackedSkeleton.Joints[JointType.HandLeft].Position,DepthImageFormat.Resolution640x480Fps30);
                 RightHandLocation=new Point(point1.X,point1.Y);
                 LeftHandLocation=new Point(point2.X,point2.Y);
                 MiddlePoint=new Point((point1.X+point2.X)/2.0,(point1.Y+point2.Y)/2.0);
                 var angle=(int)(Math.Atan(-(((double)point2.Y-point1.Y)/(point2.X-point1.X)))*(180.0/Math.PI));
                 Angle=point1.X<point2.X?point1.Y<point2.Y?angle+180:angle-180:angle;
             }
     return;
 }
开发者ID:abcsharp,项目名称:KinectControls,代码行数:28,代码来源:HandVolume.cs

示例8: Kinect_SkeletonFrameReadyTwo

        //Eventhanterare för andra skeletet
        public void Kinect_SkeletonFrameReadyTwo(object sender, SkeletonFrameReadyEventArgs e)
        {
            SkeletonsPanelTwo.Children.Clear();

            if (this.IsEnabled)
            {
                using (SkeletonFrame frame = e.OpenSkeletonFrame())
                {
                    if (frame != null)
                    {
                        if (this.IsEnabled)
                        {
                            frame.CopySkeletonDataTo(this._FrameSkeletons);

                            for (int i = 0; i < this._FrameSkeletons.Length; i++)
                            {
                                DrawSkeleton(this._FrameSkeletons[i], this._SkeletonBrushes[i]);

                                TrackJoint(this._FrameSkeletons[i].Joints[JointType.HandLeft], this._SkeletonBrushes[i]);
                                TrackJoint(this._FrameSkeletons[i].Joints[JointType.HandRight], this._SkeletonBrushes[i]);
                                TrackJoint(this._FrameSkeletons[i].Joints[JointType.HipLeft], this._SkeletonBrushes[i]);
                                TrackJoint(this._FrameSkeletons[i].Joints[JointType.HipRight], this._SkeletonBrushes[i]);
                                TrackJoint(this._FrameSkeletons[i].Joints[JointType.KneeLeft], this._SkeletonBrushes[i]);
                                TrackJoint(this._FrameSkeletons[i].Joints[JointType.KneeRight], this._SkeletonBrushes[i]);
                            }

                        }
                    }
                }
            }
        }
开发者ID:kulturberikare,项目名称:RUNKinect,代码行数:32,代码来源:SkeletonViewerTwo.xaml.cs

示例9: KinectOnSkeletonFrameReady

        private static void KinectOnSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs skeletonFrameReadyEventArgs)
        {
            using (var frame = skeletonFrameReadyEventArgs.OpenSkeletonFrame())
            {
                if (frame == null) return;

                //フレームに含まれる骨格情報を取得する
                var skeletonData = new Skeleton[frame.SkeletonArrayLength];
                frame.CopySkeletonDataTo(skeletonData);

                foreach (var skeleton in skeletonData)
                {
                    if (skeleton == null) continue;

                    //トラッキングできている骨格だけ取得
                    if (skeleton.TrackingState != SkeletonTrackingState.Tracked) continue;
                    foreach (Joint joint in skeleton.Joints)
                    {
                        //トラッキングできている関節だけ取得
                        if (joint.TrackingState != JointTrackingState.Tracked) continue;
                        Console.WriteLine("JointType: {0}\t X: {1} \t Y: {2} \t Z: {3}", joint.JointType, joint.Position.X, joint.Position.Y, joint.Position.Z);

                        //座標系の変換
                        var cp = (sender as KinectSensor).CoordinateMapper.MapSkeletonPointToColorPoint(joint.Position, ColorImageFormat.RawBayerResolution640x480Fps30);
                        Console.WriteLine("RGB X: {0} \t RGB Y: {1}", cp.X, cp.Y);
                    }
                }
            }
        }
开发者ID:buchizo,项目名称:ITAP5,代码行数:29,代码来源:Program.cs

示例10: Nui_SkeletonFrameReady

        static void Nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            if (!_initialized) return;

            List<Skeleton> users = new List<Skeleton>();

            SkeletonFrame skeletonFrame = e.OpenSkeletonFrame();
            Skeleton[] skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];

            skeletonFrame.CopySkeletonDataTo(skeletons);

            foreach (var user in skeletons)
            {
                if (user.TrackingState == SkeletonTrackingState.Tracked)
                {
                    users.Add(user);
                }
            }

            if (users.Count > 0)
            {
                string json = users.Serialize();

                foreach (var socket in _sockets)
                {
                    socket.Send(json);
                }
            }
        }
开发者ID:uniphil,项目名称:FitHub,代码行数:29,代码来源:Program.cs

示例11: SensorSkeletonFrameReady

        private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs skeletonFrameReadyEventArgs)
        {
            
            using (SkeletonFrame skeletonFrame = skeletonFrameReadyEventArgs.OpenSkeletonFrame())
            {
                if (skeletonFrame == null)
                    return;

                
                try
                {
                    

                    skeletonFrame.CopySkeletonDataTo(skeletons);
                    var accelerometerReading = sensor.AccelerometerGetCurrentReading();
                    interactionStream.ProcessSkeleton(skeletons, accelerometerReading, skeletonFrame.Timestamp);

                   
                }
                catch (InvalidOperationException)
                {
                    // SkeletonFrame functions may throw when the sensor gets
                    // into a bad state.  Ignore the frame in that case.
                }
            }
        }
开发者ID:GregWard,项目名称:Tronsformers,代码行数:26,代码来源:KinectEvents.cs

示例12: Sensor_SkeletonFrameReady

		void Sensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
		{
			using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
			{
				skeletonFrame.CopySkeletonDataTo(this.FSkeletons);
			}
		}
开发者ID:kevinbs,项目名称:VVVV.Packs.Image,代码行数:7,代码来源:Skeleton.cs

示例13: myKinect_AllFramesReady

        private void myKinect_AllFramesReady(Object sender,SkeletonFrameReadyEventArgs e)
        {
            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame != null)
                {
                    if (this.skeletonData == null || (this.skeletonData.Length != skeletonFrame.SkeletonArrayLength))
                    {
                        this.skeletonData = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    }

                    skeletonFrame.CopySkeletonDataTo(skeletonData);

                    foreach(Skeleton skeleton in skeletonData)
                    {
                        if(skeleton.TrackingState == SkeletonTrackingState.Tracked)
                        {
                            double x = 0, y = 0, z = 0;
                            Joint joint = skeleton.Joints[JointType.HandRight];
                            x = joint.Position.X;
                            y = joint.Position.Y;
                            z = joint.Position.Z;
                            tRightHand.Content = "X: " + x + " \nY: " + y + " \nZ: " + z;
                            if (x > 0.5)
                            {
                                tRightHand.Foreground = Brushes.Red;
                            } else
                            {
                                tRightHand.Foreground = Brushes.Black;
                            }
                        }
                    }
                }
            }
        }
开发者ID:Broams,项目名称:holography,代码行数:35,代码来源:MainWindow.xaml.cs

示例14: miKinect_SkeletonFrameReady

        private void miKinect_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            canvasesqueleto.Children.Clear();
            Skeleton[] esqueletos = null;

            using (SkeletonFrame frameEsqueleto = e.OpenSkeletonFrame()) {
                if (frameEsqueleto != null) {
                    esqueletos = new Skeleton[frameEsqueleto.SkeletonArrayLength];
                    frameEsqueleto.CopySkeletonDataTo(esqueletos);
                }
            }

            if (esqueletos == null) return;

            foreach (Skeleton esqueleto in esqueletos) {
                if (esqueleto.TrackingState == SkeletonTrackingState.Tracked) { 
                    Joint handJoint = esqueleto.Joints[JointType.HandRight];
                    Joint elbowJoint = esqueleto.Joints[JointType.ElbowRight];

                    Line huesoBrazoDer = new Line();
                    huesoBrazoDer.Stroke = new SolidColorBrush(Colors.Red);
                    huesoBrazoDer.StrokeThickness = 5;

                    ColorImagePoint puntoMano = miKinect.CoordinateMapper.MapSkeletonPointToColorPoint(handJoint.Position, ColorImageFormat.RgbResolution640x480Fps30);
                    huesoBrazoDer.X1 = puntoMano.X;
                    huesoBrazoDer.Y1 = puntoMano.Y;

                    ColorImagePoint puntoCodo = miKinect.CoordinateMapper.MapSkeletonPointToColorPoint(elbowJoint.Position, ColorImageFormat.RgbResolution640x480Fps30);
                    huesoBrazoDer.X2 = puntoCodo.X;
                    huesoBrazoDer.Y2 = puntoCodo.Y;

                    canvasesqueleto.Children.Add(huesoBrazoDer);
                }
            }
        }
开发者ID:egaleano,项目名称:Kinect,代码行数:35,代码来源:MainWindow.xaml.cs

示例15: Sensor_SkeletonFrameReady

        void Sensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            using (var frame = e.OpenSkeletonFrame())
            {
                if (frame != null)
                {
                    canvas.ClearSkeletons();
                    tblHeights.Text = string.Empty;

                    var skeletons = frame.Skeletons().Where(s => s.TrackingState == SkeletonTrackingState.Tracked);

                    foreach (var skeleton in skeletons)
                    {
                        if (skeleton != null)
                        {
                            // Update skeleton gestures.
                            _gestureController.Update(skeleton);

                            // Draw skeleton.
                            canvas.DrawSkeleton(skeleton);

                            // Display user height.
                            tblHeights.Text += string.Format("\nUser {0}: {1}cm", skeleton.TrackingId, skeleton.Height());
                        }
                    }
                }
            }
        }
开发者ID:etrigger,项目名称:Vitruvius,代码行数:28,代码来源:MainWindow.xaml.cs


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