Esempio n. 1
0
        public static BVH_IO Record_Start(Body body, KinectSkeleton skel, string fileName, string path)
        {
            try
            {
                int initFrames = 10;

                BVH_IO bfhFile = new BVH_IO(fileName, path);

                if (bfhFile != null)
                {
                    if (bfhFile.isRecording == true && bfhFile.isInitializing == true)
                    {
                        bfhFile.Entry(skel);

                        //if (bfhFile.intializingCounter > initFrames)
                        //{
                        bfhFile.startWritingEntry();
                        //  }
                    }

                    if (bfhFile.isRecording == true && bfhFile.isInitializing == false)
                    {
                        bfhFile.WriteMotions(skel, body);
                        //this.textBox_sensorStatus.Text = "Record";
                        //this.textBox_sensorStatus.BackColor = Color.Green;
                    }
                }
                return(bfhFile);
            }
            catch (Exception err)
            {
                System.Windows.Forms.MessageBox.Show("Error in BVH_IO.Record_Start: " + err.Message);
                return(null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the body frame data arriving from the sensor
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void BodyReader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
            bool dataReceived = false;

            using (BodyFrame bodyFrame = e.FrameReference.AcquireFrame())
            {
                if (bodyFrame != null)
                {
                    if (this.bodies == null)
                    {
                        this.bodies = new Body[bodyFrame.BodyCount];
                    }


                    // The first time GetAndRefreshBodyData is called, Kinect will allocate each Body in the array.
                    // As long as those body objects are not disposed and not set to null in the array,
                    // those body objects will be re-used.
                    bodyFrame.GetAndRefreshBodyData(this.bodies);
                    dataReceived = true;
                }
            }

            if (dataReceived)
            {
                // Draw a transparent background to set the render size
                //dc.DrawRectangle(Brushes.Black, null, new Rect(0.0, 0.0, this.displayWidth, this.displayHeight));

                foreach (Body body in this.bodies)
                {
                    //Pen drawPen = this.bodyColors[penIndex++];

                    if (body.IsTracked)
                    {
                        this.kinectSkeleton.Update(body, this.coordinateMapper);
                        if (isRecording && this.BVHFile != null)
                        {
                            BVHFile.WriteMotions(kinectSkeleton, body);
                        }
                    }
                }
            }
        }