public void Stop_record() { if (BVHFile != null) { BVHFile.closeBVHFile(); Console.WriteLine("recording saved"); BVHFile = null; if (BVHFile != null) { Console.WriteLine("BVHFile != null"); } } }
public void Kinect_start(string smooth) { if (sensor == null) { // Look through all sensors and start the first connected one. // This requires that a Kinect is connected at the time of app startup. // To make your app robust against plug/unplug, // it is recommended to use KinectSensorChooser provided in Microsoft.Kinect.Toolkit (See components in Toolkit Browser). foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { this.sensor = potentialSensor; break; } } //----OPEN BVHfile to write---------------------------------------------------- if (BVHFile == null && sensor != null) { Console.WriteLine("File initialize."); DateTime thisDay = DateTime.UtcNow; string txtFileName = thisDay.ToString("dd.MM.yyyy_HH.mm"); BVHFile = new writeBVH(txtFileName); Console.WriteLine("File name : {0}.bvh", txtFileName); //Console.WriteLine("+++{0}+++", BVHFile.bvhSkeletonWritten.Bones.Count); } //----------------------------------------------------------- if (null != this.sensor) { TransformSmoothParameters smoothingParam = new TransformSmoothParameters(); if (smooth == "Default") { // Some smoothing with little latency (defaults). // Only filters out small jitters. // Good for gesture recognition in games. smoothingParam = new TransformSmoothParameters(); { smoothingParam.Smoothing = 0.5f; smoothingParam.Correction = 0.5f; smoothingParam.Prediction = 0.5f; smoothingParam.JitterRadius = 0.05f; smoothingParam.MaxDeviationRadius = 0.04f; }; } else if (smooth == "Moderate") { // Smoothed with some latency. // Filters out medium jitters. // Good for a menu system that needs to be smooth but // doesn't need the reduced latency as much as gesture recognition does. smoothingParam = new TransformSmoothParameters(); { smoothingParam.Smoothing = 0.5f; smoothingParam.Correction = 0.1f; smoothingParam.Prediction = 0.5f; smoothingParam.JitterRadius = 0.1f; smoothingParam.MaxDeviationRadius = 0.1f; }; } else if (smooth == "Intense") { // Very smooth, but with a lot of latency. // Filters out large jitters. // Good for situations where smooth data is absolutely required // and latency is not an issue. smoothingParam = new TransformSmoothParameters(); { smoothingParam.Smoothing = 0.7f; smoothingParam.Correction = 0.3f; smoothingParam.Prediction = 1.0f; smoothingParam.JitterRadius = 1.0f; smoothingParam.MaxDeviationRadius = 1.0f; }; } // Turn on the stream to receive frames this.sensor.SkeletonStream.Enable(smoothingParam); // event handler to be called whenever there is new frame data this.sensor.AllFramesReady += sensor_allFramesReady; // Start the sensor! try { this.sensor.Start(); Console.WriteLine("started stream"); Console.WriteLine("Please stand ahead the Kinect until it catch you and print the BVHFile Head."); } catch (Exception) { this.sensor = null; Console.WriteLine("Stream could not be started"); } } else { Console.WriteLine("No Kinect found"); } } }