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

            using (quadro)
                quadro.DesenharEsqueletoUsuario(kinect, canvasKinect);
        }
Exemplo n.º 2
0
        public void Record(SkeletonFrame frame)
        {
            // Header
              writer.Write((int)KinectRecordOptions.Skeletons);

              // Data
              var time = DateTime.Now;
              TimeSpan timeSpan = time.Subtract(referenceTime);
              referenceTime = time;
              writer.Write((long)timeSpan.TotalMilliseconds);
              writer.Write((int)frame.TrackingMode);
              writer.Write(frame.FloorClipPlane.Item1);
              writer.Write(frame.FloorClipPlane.Item2);
              writer.Write(frame.FloorClipPlane.Item3);
              writer.Write(frame.FloorClipPlane.Item4);

              writer.Write(frame.FrameNumber);

              // Skeletons
              Skeleton[] skeletons = frame.GetSkeletons();
              frame.CopySkeletonDataTo(skeletons);

              BinaryFormatter formatter = new BinaryFormatter();
              formatter.Serialize(writer.BaseStream, skeletons);
        }
Exemplo n.º 3
0
        private void ExecutaRegraMaoDireitaAcimaDaCabeca(SkeletonFrame quadroAtual)
        {
            Skeleton[] esqueletos = new Skeleton[6];
            quadroAtual.CopySkeletonDataTo(esqueletos);

            Skeleton usuario = esqueletos.FirstOrDefault(esqueleto => esqueleto.TrackingState == SkeletonTrackingState.Tracked);

            if(usuario != null)
            {
                Joint maoDireita = usuario.Joints[JointType.HandRight];
                Joint maoEsquerda = usuario.Joints[JointType.HandLeft];
                Joint cabeca = usuario.Joints[JointType.Head];

                LmaoDireita.Content = maoDireita.Position.X.ToString();
                LmaoEsquerda.Content = maoEsquerda.Position.X.ToString();
                Lcabeca.Content = cabeca.Position.X.ToString();

                LmaoEsquerdaY.Content = maoEsquerda.Position.Y.ToString();
                LmaoDireitaY .Content = maoDireita.Position.Y.ToString();
                LcabecaY.Content = cabeca.Position.Y.ToString();

                bool novoTesteMaoDireitaAcimaCabeca = maoDireita.Position.Y > cabeca.Position.Y;

                if(MaoDireitaAcimaCabeca != novoTesteMaoDireitaAcimaCabeca)
                {
                    MaoDireitaAcimaCabeca = novoTesteMaoDireitaAcimaCabeca;

                    if(MaoDireitaAcimaCabeca)
                    {
                        MessageBox.Show("Mao direita acima da cabeca.");
                    }
                }
            }
        }
Exemplo n.º 4
0
	public float[] WriteSkeletonToFile(Skeleton skeleton, SkeletonFrame skeletonFrame, System.IO.StreamWriter file)
	{

        int count = 2; 
            float[] dataLine = new float[63];
            System.Text.StringBuilder sb = new System.Text.StringBuilder(150);
            string str_framenum = skeletonFrame.FrameNumber.ToString();
            dataLine[0] = float.Parse(str_framenum);
            sb.Append(str_framenum);
            sb.Append(" , ");
            string str_timestamp = skeletonFrame.Timestamp.ToString();
            dataLine[1] = float.Parse(str_timestamp);
            sb.Append(str_timestamp);
            sb.Append(" , ");

            foreach (Joint joint in skeleton.Joints){

                dataLine[count] = joint.Position.X;
                sb.Append(joint.Position.X.ToString());
                sb.Append(" , ");
                dataLine[count + 1] = joint.Position.Y;
                sb.Append(joint.Position.Y.ToString());
                sb.Append(" , ");
                dataLine[count + 2] = joint.Position.Z;
                sb.Append(joint.Position.Z.ToString());
                sb.Append(" , ");
                count = count + 3;
            }

            string str = sb.ToString();
         
            file.WriteLine(str);
            return dataLine;
	}
Exemplo n.º 5
0
        public void OnAllFramesReady(ColorImageFrame colorImageFrame, DepthImageFrame depthImageFrame, SkeletonFrame skeletonFrame)
        {
            string stat = "";
            // Face tracking / timing stuff
            if (FaceList.Count > 0) {
                foreach (Face f in FaceList.toList()) {
                    stat += "    {" + f.Id + ", " + String.Format("{0:0.00}", f.Velocity) + "}";
                    if (f.TakePicture) {
                        int[] coordsExpanded = expandBy(f.Coords, 250, colorImageFrame.Width - 1, colorImageFrame.Height - 1);
                        if (coordsExpanded[2] == 0 || coordsExpanded[3] == 0) // width or height can't be 0
                            continue;
                        string time = System.DateTime.Now.ToString("hh'-'mm'-'ss", CultureInfo.CurrentUICulture.DateTimeFormat);
                        string path = "..\\..\\Images\\CroppedPics\\pic" + f.Id + "--" + time + ".jpg";
                        f.Path = path;
                        bool success = SaveImage(path, cropImage(colorImageFrame, coordsExpanded), ImageFormat.Jpeg);
                        if (success && USE_BETAFACE) {
                            bfw.enqueue(f);
                            f.ProcessingBetaface = true;

                        }
                    }

                }
            }
            FaceTracking.Status = stat;
            FaceTracking.Status = "";
        }
Exemplo n.º 6
0
 public ReplaySkeletonFrame(SkeletonFrame frame)
 {
     FloorClipPlane = frame.FloorClipPlane;
     FrameNumber = frame.FrameNumber;
     TimeStamp = frame.Timestamp;
     Skeletons = Tools.GetSkeletons(frame);
 }
Exemplo n.º 7
0
        public WriteableBitmap bmpFromColorFrame(ColorImageFrame NewFrame, bool SkeletonWanted, SkeletonFrame SkelFrame)
        {
            if (bmpColor == null)
            {
                bmpColor = new WriteableBitmap(frameWidth, frameHeight, 96, 96, PixelFormats.Bgr32, null);
            }

            if (NewFrame == null)
            {
                throw new InvalidOperationException("Null Image");
            }

            NewFrame.CopyPixelDataTo(colorPixels);
            // Write the pixel data into our bitmap
            bmpColor.WritePixels(
            new Int32Rect(0, 0, bmpColor.PixelWidth, bmpColor.PixelHeight),
                colorPixels,
                bmpColor.PixelWidth * sizeof(int),
                0);
            //Skeleton
            if (SkeletonWanted != false && SkelFrame != null)
            {
                return bmpWithSkelFromColor(bmpColor, SkelFrame);
            }
            return bmpColor;
        }
Exemplo n.º 8
0
		public ReplaySkeletonFrame(SkeletonFrame frame)
		{
			FloorClipPlane = frame.FloorClipPlane;
			FrameNumber = frame.FrameNumber;
			TimeStamp = frame.Timestamp;
            //Skeletons = frame.GetSkeletons();
			TrackingMode = frame.TrackingMode;
		}
 /// <summary>
 /// Public constructor from SkeletonDataFrame
 /// </summary>
 /// <param name="skeletonFrame">Skeleton Frame</param>
 public SkeletonDataFrame(kinect.SkeletonFrame skeletonFrame)
 {
     this.FrameNumber    = skeletonFrame.FrameNumber;
     this.FloorClipPlane = skeletonFrame.FloorClipPlane;
     this.Timestamp      = skeletonFrame.Timestamp;
     this.SkeletonData   = new kinect.Skeleton[skeletonFrame.SkeletonArrayLength];
     skeletonFrame.CopySkeletonDataTo(this.SkeletonData);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Process data from one Kinect skeleton frame.
        /// </summary>
        /// <param name="skeletons">
        /// Kinect skeleton data.
        /// </param>
        /// <param name="skeletonFrame">
        /// <see cref="SkeletonFrame"/> from which we obtained skeleton data.
        /// </param>
        public override void ProcessSkeleton(Skeleton[] skeletons, SkeletonFrame skeletonFrame)
        {
            if (skeletonFrame == null)
            {
                throw new ArgumentNullException("skeletonFrame");
            }

            this.ProcessSkeletonAsync(skeletons, skeletonFrame.Timestamp);
        }
Exemplo n.º 11
0
        void Kinect_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            if(ClientList.Count > 0)
            {
                using(SkeletonFrame frame = e.OpenSkeletonFrame())
                {
                    this.SkeletonFrame = frame;

                    if(frame != null)
                    {
                        _memoryStream.Seek(0, SeekOrigin.Begin);

                        if(_skeletons == null || _skeletons.Length != frame.SkeletonArrayLength)
                            _skeletons = new Skeleton[frame.SkeletonArrayLength];

                        frame.CopySkeletonDataTo(_skeletons);

                        _binaryWriter.Write(frame.FloorClipPlane.Item1);
                        _binaryWriter.Write(frame.FloorClipPlane.Item2);
                        _binaryWriter.Write(frame.FloorClipPlane.Item3);
                        _binaryWriter.Write(frame.FloorClipPlane.Item4);
                        _binaryWriter.Write(frame.FrameNumber);
                        _binaryWriter.Write(frame.SkeletonArrayLength);
                        _binaryWriter.Write(frame.Timestamp);

                        foreach(Skeleton s in _skeletons)
                        {
                            _binaryWriter.Write((int)s.ClippedEdges);
                            _binaryWriter.Write(s.Joints.Count);
                            foreach(Joint j in s.Joints)
                            {
                                _binaryWriter.Write((int)j.JointType);
                                _binaryWriter.Write(j.Position.X);
                                _binaryWriter.Write(j.Position.Y);
                                _binaryWriter.Write(j.Position.Z);
                                _binaryWriter.Write((int)j.TrackingState);
                            }
                            _binaryWriter.Write(s.Position.X);
                            _binaryWriter.Write(s.Position.Y);
                            _binaryWriter.Write(s.Position.Z);
                            _binaryWriter.Write(s.TrackingId);
                            _binaryWriter.Write((int)s.TrackingState);
                        }

                        Parallel.For(0, ClientList.Count, index =>
                        {
                            SocketClient sc = ClientList[index];

                            sc.Send(BitConverter.GetBytes((int)_memoryStream.Length));
                            sc.Send(_memoryStream.ToArray());
                        });

                        RemoveClients();
                    }
                }
            }
        }
Exemplo n.º 12
0
        // three methods to record specific frames (color, depth, and skeleton):
        public void Record(SkeletonFrame frame)
        {
            if (writer == null)
                throw new Exception("This recorder is stopped");

            if (skeletonRecorder == null)
                throw new Exception("Skeleton recording is not actived on this KinectRecorder");

            skeletonRecorder.Record(frame);
        }
Exemplo n.º 13
0
Arquivo: Tools.cs Projeto: dtx/KMPC
        public static Skeleton[] GetSkeletons(SkeletonFrame frame)
        {
            if (frame == null)
                return null;

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

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

            using (quadro)
            {
                if (chkEsqueleto.IsChecked.HasValue && chkEsqueleto.IsChecked.Value)
                    quadro.DesenharEsqueletoUsuario(kinect, canvasKinect);
            }
        }
Exemplo n.º 15
0
Arquivo: Tools.cs Projeto: dtx/KMPC
        public static void GetSkeletons(SkeletonFrame frame, ref Skeleton[] skeletons)
        {
            if (frame == null)
                return;

            if (skeletons == null || skeletons.Length != frame.SkeletonArrayLength)
            {
                skeletons = new Skeleton[frame.SkeletonArrayLength];
            }
            frame.CopySkeletonDataTo(skeletons);
        }
Exemplo n.º 16
0
        public Skeleton GetFirstTrackedSkeleton(SkeletonFrame frame)
        {
            var skeletonData = new Skeleton[frame.SkeletonArrayLength];
            frame.CopySkeletonDataTo(skeletonData);

            var trackedSkel = TrackNearerSkeleton(skeletonData);

            var skeleton = (from s in skeletonData
                                 where s.TrackingState == SkeletonTrackingState.Tracked
                                    && s.TrackingId == trackedSkel
                                 select s).FirstOrDefault();
            return skeleton;
        }
Exemplo n.º 17
0
        public void synchronize(
            DepthImageFrame depthFrame,
            ColorImageFrame colorFrame,
            SkeletonFrame skletonFrame,
            Boolean isPauseMode
            )
        {
            IsPauseMode = isPauseMode;
            colorFrame.CopyPixelDataTo(_colorByte);

            //Console.WriteLine("max depth: "+depthFrame.MaxDepth);
            depthFrame.CopyDepthImagePixelDataTo(_depthPixels);

            _sensor.CoordinateMapper.MapColorFrameToDepthFrame(
                ColorImageFormat.RgbResolution640x480Fps30,
                DepthImageFormat.Resolution640x480Fps30,
                _depthPixels,
                _depthPoint
                );

            for (int i = 0; i < _pixelDepthDataLength; i++)
            {
                _depthShort[i] = (short)_depthPoint[i].Depth;
                _depthByte[i] = (byte)(_depthPoint[i].Depth*0.064-1);
            }

            skletonFrame.CopySkeletonDataTo(totalSkeleton);
            Skeleton firstSkeleton = (from trackskeleton in totalSkeleton
                                      where trackskeleton.TrackingState == SkeletonTrackingState.
                                      Tracked
                                      select trackskeleton).FirstOrDefault();

            _isCreation = true;
            if (firstSkeleton != null)
            {
                if (firstSkeleton.Joints[JointType.Spine].TrackingState == JointTrackingState.Tracked)
                {
                    IsSkeletonDetected = true;
                    UserSkeleton[SkeletonDataType.RIGHT_HAND] =
                        ScalePosition(firstSkeleton.Joints[JointType.HandRight].Position);
                    UserSkeleton[SkeletonDataType.LEFT_HAND] =
                        ScalePosition(firstSkeleton.Joints[JointType.HandLeft].Position);
                    UserSkeleton[SkeletonDataType.SPINE] =
                        ScalePosition(firstSkeleton.Joints[JointType.Spine].Position);
                    return;
                }
            }
            IsSkeletonDetected = false;
            _isCreation = false;
        }
Exemplo n.º 18
0
        /// <summary>
        /// Event handler for Kinect sensor's SkeletonFrameReady event
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void SensorSkeletonFrameReady(object sender, kinect.SkeletonFrameReadyEventArgs e)
        {
            kinect.Skeleton[] skeletons = new kinect.Skeleton[0];

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

            processSkeletons(skeletons);
        }
Exemplo n.º 19
0
        void Context_AllFramesUpdated(KinectSensor sensor, ColorImageFrame cf, DepthImageFrame df, SkeletonFrame sf)
        {
            this.sensor = sensor;
            if (colorImage == null)
            {
                colorImage = new byte[cf.PixelDataLength];
                depthImage = new short[df.PixelDataLength];
                skeletonData = new Skeleton[sf.SkeletonArrayLength];
            }

            cf.CopyPixelDataTo(colorImage);
            df.CopyPixelDataTo(depthImage);
            sf.CopySkeletonDataTo(skeletonData);

            TrackFace();
        }
Exemplo n.º 20
0
        /// <summary>
        /// 交差点の描画
        /// </summary>
        /// <param name="kinect"></param>
        /// <param name="skeletonFrame"></param>
        private void DrawCrossPoint( KinectSensor kinect, SkeletonFrame skeletonFrame )
        {
            // 描画する円の半径
              const int R = 5;

              // キャンバスをクリアする
              canvas.Children.Clear();

              // スケルトンから4か所の座標を取得(左肘・手、右肘・手)
              var joints = GetFourSkeletonPosition( skeletonFrame, JointType.ElbowLeft, JointType.HandLeft,
            JointType.ElbowRight, JointType.HandRight );
              if ( joints == null ) {
            return;
              }

              // スケルトン座標をRGB画像の座標に変換し表示する
              ColorImagePoint[] jointImagePosition = new ColorImagePoint[4];
              for ( int i = 0; i < 4; i++ ) {
            jointImagePosition[i] =
            kinect.MapSkeletonPointToColor( joints[i].Position, kinect.ColorStream.Format );

            canvas.Children.Add( new Ellipse()
            {
              Fill = new SolidColorBrush( Colors.Yellow ),
              Margin = new Thickness( jointImagePosition[i].X - R, jointImagePosition[i].Y - R, 0, 0 ),
              Width = R * 2,
              Height = R * 2,
            } );
              }

              // 腕がクロスしているかチェック
              bool isCross = CrossHitCheck( joints[0].Position, joints[1].Position,
            joints[2].Position, joints[3].Position );
              if ( isCross ) {
            // クロスしている点を計算して円を表示する
            ColorImagePoint crossPoint = GetCrossPoint( jointImagePosition[0], jointImagePosition[1],
              jointImagePosition[2], jointImagePosition[3] );

            CrossEllipse.Margin = new Thickness( crossPoint.X - CrossEllipse.Width / 2,
              crossPoint.Y - CrossEllipse.Height / 2, 0, 0 );
            CrossEllipse.Visibility = System.Windows.Visibility.Visible;
            canvas.Children.Add( CrossEllipse );
              }
              else {
            CrossEllipse.Visibility = System.Windows.Visibility.Hidden;
              }
        }
Exemplo n.º 21
0
        private void FuncoesEsqueletoUsuario(SkeletonFrame quadro)
        {
            if (quadro == null) return;
            using (quadro)
            {
                Skeleton primeiroUsuario = quadro.ObterEsqueletoPrimeiroUsuario();

                foreach(IRastreador rastreador in Rastreadores)
                {
                    rastreador.Rastrear(primeiroUsuario);
                }

                if (IsDesenhaEsqueleto())
                {
                    quadro.DesenharEsqueletoUsuario(Kinect, canvasKinect);
                }
            }
        }
        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);
                }
            }
        }
Exemplo n.º 23
0
        public void Record(SkeletonFrame frame)
        {
            if (writer == null)
                throw new Exception("You must call Start before calling Record");

            TimeSpan timeSpan = DateTime.Now.Subtract(referenceTime);
            referenceTime = DateTime.Now;
            writer.Write((long)timeSpan.TotalMilliseconds);
            writer.Write(frame.FloorClipPlane.Item1);
            writer.Write(frame.FloorClipPlane.Item2);
            writer.Write(frame.FloorClipPlane.Item3);
            writer.Write(frame.FloorClipPlane.Item4);

            Skeleton[] skeletons = Tools.GetSkeletons(frame);
            frame.CopySkeletonDataTo(skeletons);

            BinaryFormatter formatter = new BinaryFormatter();
            formatter.Serialize(writer.BaseStream, skeletons);
        }
 private void ExecutarRegraMaoDireitaAcimaDaCabeca(SkeletonFrame quadroAtual)
 {
     Skeleton[] esqueletos = new Skeleton[6];
     quadroAtual.CopySkeletonDataTo(esqueletos);
     Skeleton usuario = esqueletos.FirstOrDefault(esqueleto => esqueleto.TrackingState == SkeletonTrackingState.Tracked);
     if (usuario != null)
     {
         Joint maoDireita = usuario.Joints[JointType.HandRight];
         Joint cabeca = usuario.Joints[JointType.Head];
         bool novoTesteMaoDireitaAcimaCabeca = maoDireita.Position.Y > cabeca.Position.Y;
         if (MaoDireitaAcimaCabeca != novoTesteMaoDireitaAcimaCabeca)
         {
             MaoDireitaAcimaCabeca = novoTesteMaoDireitaAcimaCabeca;
             if (MaoDireitaAcimaCabeca)
             {
                 MessageBox.Show("A mão direita está acima da cabeça!");
             }
         }
     }
 }
Exemplo n.º 25
0
        public static ReplaySkeletonFrame FromSkeletonFrame(SkeletonFrame frame)
        {
            ReplaySkeleton[] skeletonData = new ReplaySkeleton[frame.SkeletonArrayLength];
            Skeleton[] frameSkeletonData = new Skeleton[frame.SkeletonArrayLength];
            frame.CopySkeletonDataTo(frameSkeletonData);

            for (int i = 0; i < frame.SkeletonArrayLength; i++)
            {
                Skeleton skeleton = frameSkeletonData[i];
                skeletonData[i] = ReplaySkeleton.FromSkeleton(skeleton);
            }

            return new ReplaySkeletonFrame()
            {
                FrameNumber = frame.FrameNumber,
                FloorClipPane = ReplaySkeletonFrameFloorClipPane.FromTuple(frame.FloorClipPlane),
                SkeletonArrayLength = frame.SkeletonArrayLength,
                SkeletonData = skeletonData,
                TrackingMode = frame.TrackingMode
            };
        }
Exemplo n.º 26
0
        public void Update(SkeletonFrame frame)
        {
            if (isRunning == false)
            {
                return;
            }

            Skeleton [] skeletons = Tools.GetSkeletons(frame);

            foreach (var skeleton in skeletons)
            {
                if (skeleton.TrackingState != SkeletonTrackingState.Tracked)
                    continue;
                // just the 1st skeleton at the moment
                
                //TrackGestures(skeleton);

                

            }

        }
        /// <summary>
        /// 指定された点により近いユーザーをアクティブにする
        /// </summary>
        /// <param name="skeletons"></param>
        public static void SetActivePlayerAtCenter( SkeletonStream stream, SkeletonFrame frame, SkeletonPoint centerPosition )
        {
            Skeleton player = null;
            double distance = 100;

            var skeletons = frame.ToSkeletonData();
            foreach ( var skeleton in skeletons ) {
                if ( skeleton.TrackingState != SkeletonTrackingState.NotTracked ) {
                    double new_ = Distance_XY( centerPosition, skeleton.Position );
                    if ( (new_ < distance) ) {
                        player = skeleton;
                        distance = new_;
                    }
                }
            }

            if ( player != null ) {
                stream.ChooseSkeletons( player.TrackingId );
            }
            else {
                stream.ChooseSkeletons();
            }
        }
Exemplo n.º 28
0
        public Option<HandInputEvent> Update(SkeletonFrame sf, byte[] cf)
        {
            if (sf != null) {
            if (skeletonData == null || skeletonData.Length != sf.SkeletonArrayLength) {
              skeletonData = new Skeleton[sf.SkeletonArrayLength];
            }

            sf.CopySkeletonDataTo(skeletonData);
            var trackedIndex = SkeletonUtil.FirstTrackedSkeletonIndex(skeletonData);
            if (trackedIndex >= 0) {
              var skeleton = skeletonData[trackedIndex];
              var handRight = SkeletonUtil.GetJoint(skeleton, JointType.HandRight);
              var handLeft = SkeletonUtil.GetJoint(skeleton, JointType.HandLeft);

              var handRightPos = coordMapper.MapSkeletonPointToDepthPoint(handRight.Position,
              DepthImageFormat.Resolution640x480Fps30);
              var handLeftPos = coordMapper.MapSkeletonPointToDepthPoint(handLeft.Position,
              DepthImageFormat.Resolution640x480Fps30);
              return new Some<HandInputEvent>(new HandInputEvent(handLeftPos, handRightPos));
            }
              }
              return new None<HandInputEvent>();
        }
Exemplo n.º 29
0
        /// <summary>
        /// 停止状態にあるかチェックする
        /// </summary>
        /// <param name="skeletonFrame"></param>
        /// <param name="point"></param>
        /// <returns></returns>
        bool IsSteady( SkeletonFrame skeletonFrame, ColorImagePoint point )
        {
            var currentPoint = new FramePoint()
              {
            Point = point,
            TimeStamp = skeletonFrame.Timestamp,
              };

              // milliseconds時間経過したら steady
              if ( (currentPoint.TimeStamp - basePoint.TimeStamp) > milliseconds ) {
            basePoint = currentPoint;
            return true;
              }

              // 座標の変化量がthreshold以上ならば、basePointを更新して初めから計測
              if ( Math.Abs( currentPoint.Point.X - basePoint.Point.X ) > threshold
            || Math.Abs( currentPoint.Point.Y - basePoint.Point.Y ) > threshold ) {

            // 座標が動いたので基点を動いた位置にずらして、最初から計測
            basePoint = currentPoint;
              }

              return false;
        }
Exemplo n.º 30
0
 private void WriteImageSkeleton(SkeletonFrame frame)
 {
     foreach (Skeleton skeleton in this._skeletonData)
        {
        if (skeleton.TrackingState == SkeletonTrackingState.Tracked && _movieRecordingOn)
        {
           this._ImageSkelFile.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22},{23},{24},{25},{26},{27},{28},{29}, {30}, {31}, {32}, {33}, {34},{35},{36},{37},{38},{39}",
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.Head].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.Head].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.ShoulderCenter].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.ShoulderCenter].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.ShoulderLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.ShoulderLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.ElbowLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.ElbowLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.WristLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.WristLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.HandLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.HandLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.ShoulderRight].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.ShoulderRight].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.ElbowRight].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.ElbowRight].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.WristRight].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.WristRight].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.HandRight].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.HandRight].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.Spine].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.Spine].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.HipCenter].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.HipCenter].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.HipLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.HipLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.KneeLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.KneeLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.AnkleLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.AnkleLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.FootLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.FootLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.HipRight].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.HipRight].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.KneeRight].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.KneeRight].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.AnkleRight].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.AnkleRight].Position, ColorImageFormat.RgbResolution640x480Fps30).Y,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.FootRight].Position, ColorImageFormat.RgbResolution640x480Fps30).X,
                this._sensor.CoordinateMapper.MapSkeletonPointToColorPoint(skeleton.Joints[JointType.FootRight].Position, ColorImageFormat.RgbResolution640x480Fps30).Y);
        }
        }
 }
Exemplo n.º 31
0
        private void AccessSkeletonData(SkeletonFrame skeletonFrame)
        {
            if (this._skelFrameCount == 0)
            {
                this._firstSkelFrameTimestamp = skeletonFrame.Timestamp;
            }

            foreach (Skeleton skeleton in this._skeletonData)
            {
                if (skeleton.TrackingState == SkeletonTrackingState.Tracked && _skeletonRecordingOn)
                {
                    this._skelFrameTime = ((float)(skeletonFrame.Timestamp - this._firstSkelFrameTimestamp)) / 1000f;
                    radioButton1.IsChecked = true;
                   _DataFile.WriteLine( "{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22},{23},{24},{25},{26},{27},{28},{29}, {30}, {31}, {32}, {33}, {34},{35},{36},{37},{38},{39},{40}, {41}, {42}, {43},{44}, {45}, {46}, {47},{48},{49}, {50},{51},{52},{53}, {54}, {55}, {56}, {57}, {58}, {59}, {60}",
                       skeleton.Joints[JointType.Head].Position.X,
                       skeleton.Joints[JointType.Head].Position.Y,
                       skeleton.Joints[JointType.Head].Position.Z,
                       skeleton.Joints[JointType.ShoulderCenter].Position.X,
                       skeleton.Joints[JointType.ShoulderCenter].Position.Y,
                       skeleton.Joints[JointType.ShoulderCenter].Position.Z,
                       skeleton.Joints[JointType.ShoulderLeft].Position.X,
                       skeleton.Joints[JointType.ShoulderLeft].Position.Y,
                       skeleton.Joints[JointType.ShoulderLeft].Position.Z,
                       skeleton.Joints[JointType.ElbowLeft].Position.X,
                       skeleton.Joints[JointType.ElbowLeft].Position.Y,
                       skeleton.Joints[JointType.ElbowLeft].Position.Z,
                       skeleton.Joints[JointType.WristLeft].Position.X,
                       skeleton.Joints[JointType.WristLeft].Position.Y,
                       skeleton.Joints[JointType.WristLeft].Position.Z,
                       skeleton.Joints[JointType.HandLeft].Position.X,
                       skeleton.Joints[JointType.HandLeft].Position.Y,
                       skeleton.Joints[JointType.HandLeft].Position.Z,
                       skeleton.Joints[JointType.ShoulderRight].Position.X,
                       skeleton.Joints[JointType.ShoulderRight].Position.Y,
                       skeleton.Joints[JointType.ShoulderRight].Position.Z,
                       skeleton.Joints[JointType.ElbowRight].Position.X,
                       skeleton.Joints[JointType.ElbowRight].Position.Y,
                       skeleton.Joints[JointType.ElbowRight].Position.Z,
                       skeleton.Joints[JointType.WristRight].Position.X,
                       skeleton.Joints[JointType.WristRight].Position.Y,
                       skeleton.Joints[JointType.WristRight].Position.Z,
                       skeleton.Joints[JointType.HandRight].Position.X,
                       skeleton.Joints[JointType.HandRight].Position.Y,
                       skeleton.Joints[JointType.HandRight].Position.Z,
                       skeleton.Joints[JointType.Spine].Position.X,
                       skeleton.Joints[JointType.Spine].Position.Y,
                       skeleton.Joints[JointType.Spine].Position.Z,
                       skeleton.Joints[JointType.HipCenter].Position.X,
                       skeleton.Joints[JointType.HipCenter].Position.Y,
                       skeleton.Joints[JointType.HipCenter].Position.Z,
                       skeleton.Joints[JointType.HipLeft].Position.X,
                       skeleton.Joints[JointType.HipLeft].Position.Y,
                       skeleton.Joints[JointType.HipLeft].Position.Z,
                       skeleton.Joints[JointType.KneeLeft].Position.X,
                       skeleton.Joints[JointType.KneeLeft].Position.Y,
                       skeleton.Joints[JointType.KneeLeft].Position.Z,
                       skeleton.Joints[JointType.AnkleLeft].Position.X,
                       skeleton.Joints[JointType.AnkleLeft].Position.Y,
                       skeleton.Joints[JointType.AnkleLeft].Position.Z,
                       skeleton.Joints[JointType.FootLeft].Position.X,
                       skeleton.Joints[JointType.FootLeft].Position.Y,
                       skeleton.Joints[JointType.FootLeft].Position.Z,
                       skeleton.Joints[JointType.HipRight].Position.X,
                       skeleton.Joints[JointType.HipRight].Position.Y,
                       skeleton.Joints[JointType.HipRight].Position.Z,
                       skeleton.Joints[JointType.KneeRight].Position.X,
                       skeleton.Joints[JointType.KneeRight].Position.Y,
                       skeleton.Joints[JointType.KneeRight].Position.Z,
                       skeleton.Joints[JointType.AnkleRight].Position.X,
                       skeleton.Joints[JointType.AnkleRight].Position.Y,
                       skeleton.Joints[JointType.AnkleRight].Position.Z,
                       skeleton.Joints[JointType.FootRight].Position.X,
                       skeleton.Joints[JointType.FootRight].Position.Y,
                       skeleton.Joints[JointType.FootRight].Position.Z,
                       this._skelFrameTime);
                   this._skelFrameCount++;

                   if (_skelFrameCount % 10 == 0)
                   {
                       this.numFramesBox.Text = _skelFrameCount.ToString();
                   }
                }
            }
        }
        /// <summary>
        /// Process data from one Kinect skeleton frame.
        /// </summary>
        /// <param name="skeletons">
        /// Kinect skeleton data.
        /// </param>
        /// <param name="skeletonFrame">
        /// <see cref="SkeletonFrame"/> from which we obtained skeleton data.
        /// </param>
        public override void ProcessSkeleton(Skeleton[] skeletons, SkeletonFrame skeletonFrame)
        {
            if (skeletons == null)
            {
                throw new ArgumentNullException("skeletons");
            }

            if (skeletonFrame == null)
            {
                throw new ArgumentNullException("skeletonFrame");
            }

            if (this.backgroundRemovalStreamIsEnabled)
            {
                this.backgroundRemovalStream.ProcessSkeleton(skeletons, skeletonFrame.Timestamp);
            }
        }