public void LoadData(ref List <InputDataType> inputData, ref List <OutputDataType> outputData) { String folderPath = "TRAINING_DATA2"; foreach (string file in Directory.EnumerateFiles(folderPath, "*.TD")) { var readFile = File.ReadAllBytes(file); var skeletonList = ReadWriteObjectFile.FromByteArray <List <Skeleton> >(readFile); foreach (Skeleton skel in skeletonList) { var output = Regex.Replace(file.ToUpper(), @"[\d-]\.TD", string.Empty).ToUpper().Split(new string[] { "\\" }, StringSplitOptions.None)[1]; outputData.Add(DataTypeResolver <OutputDataType> .CastObject(output)); inputData.Add(DataTypeResolver <InputDataType> .CastObject(skel)); } } }
private static void NameOfMethodToCall() { foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { KinectController.sensor = potentialSensor; break; } } if (null != KinectController.sensor) { TransformSmoothParameters 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 skeleton stream to receive skeleton frames KinectController.sensor.SkeletonStream.Enable(smoothingParam); // Add an event handler to be called whenever there is new color frame data KinectController.sensor.SkeletonFrameReady += SensorSkeletonFrameReady; //KinectController.postureRecognition = new PostureRecognition<Skeleton, string>(PatternType.AnglePatternElbowKnee, DataTrainingType.DataTrainingFile, 100000); //KinectController.postureRecognition.training(); KinectController.postureRecognition = ReadWriteObjectFile.FromByteArray <PostureRecognition <Skeleton, string> >(Convert.FromBase64String(DbServices.GetTrainingRed("seven", "posture"))); // Start the sensor! try { KinectController.sensor.Start(); } catch (IOException) { KinectController.sensor = null; } } //while (true) ; // This will be executed on another thread }
static void Main(string[] args) { PostureRecognition <Skeleton, string> postureRecognition = new PostureRecognition <Skeleton, string>(PatternType.AnglePatternElbowKnee, DataTrainingType.DataTrainingFile, 100000); //1000000 //Console.WriteLine("MOSTRANDO DATOS BRUTOS" + "---------------------------------------------------"); //List<Pose> poselist = LoadData("TRAINING_DATA3"); //printPoses(poselist); //Console.WriteLine("ITERACION : " + postureRecognition.training() + "-------------------------------------------------------\n"); Console.WriteLine("TESTING" + "-------------------------------------------------------"); postureRecognition = ReadWriteObjectFile.FromByteArray <PostureRecognition <Skeleton, string> >(Convert.FromBase64String(DbServices.GetTrainingRed("octavo", "posture"))); String folderPath = "TESTING"; int counter; foreach (string file in Directory.EnumerateFiles(folderPath, "*.TD")) { var readFile = File.ReadAllBytes(file); var skeletonList = ReadWriteObjectFile.FromByteArray <List <Skeleton> >(readFile); counter = 0; foreach (Skeleton skel in skeletonList) { if (counter == 7) { break; } var x = postureRecognition.Predict(skel); if (x != null && x.Length > 0) { Console.Write(x + "\n"); } counter++; } } }
public static List <Pose> LoadData(string folderPath) { List <Pose> poseslist = new List <Pose>(); //String folderPath = "TRAINING_DATA3"; foreach (string file in Directory.EnumerateFiles(folderPath, "*.TD")) { var readFile = File.ReadAllBytes(file); var skeletonList = ReadWriteObjectFile.FromByteArray <List <Skeleton> >(readFile); //Console.WriteLine("NRO: " + skeletonList.Count ); foreach (Skeleton skel in skeletonList) { var output = Regex.Replace(file.ToUpper(), @"[\d]*?\.TD", string.Empty).ToUpper().Split(new string[] { "\\" }, StringSplitOptions.None)[1]; //outputData.Add(DataTypeResolver<OutputDataType>.CastObject(output)); //inputData.Add(DataTypeResolver<InputDataType>.CastObject(skel)); //Console.WriteLine("FILE: " + output); Pose posetemp = new Pose(); posetemp.InputData = skel; posetemp.OutputData = output; poseslist.Add(posetemp); } } return(poseslist); }
/// <summary> /// Execute startup tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void WindowLoaded(object sender, RoutedEventArgs e) { // Create the drawing group we'll use for drawing this.drawingGroup = new DrawingGroup(); // Create an image source that we can use in our image control this.imageSource = new DrawingImage(this.drawingGroup); // Display the drawing using our image control Image.Source = this.imageSource; // 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; } } if (null != this.sensor) { TransformSmoothParameters 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 skeleton stream to receive skeleton frames this.sensor.SkeletonStream.Enable(smoothingParam); // Add an event handler to be called whenever there is new color frame data this.sensor.SkeletonFrameReady += this.SensorSkeletonFrameReady; //postureRecognition = new PostureRecognition<Skeleton, string>(PatternType.AnglePatternElbowKnee, DataTrainingType.DataTrainingFile, 100000); //postureRecognition.training(); //string code = Convert.ToBase64String(ReadWriteObjectFile.ObjectToByteArray(postureRecognition)); //DbServices.AddTrainingRed("seven", code, "posture"); postureRecognition = ReadWriteObjectFile.FromByteArray <PostureRecognition <Skeleton, string> >(Convert.FromBase64String(DbServices.GetTrainingRed("seven", "posture"))); ExecuteThreadServiceAsync(); StartSocketListenner(); // Start the sensor! try { this.sensor.Start(); } catch (IOException) { this.sensor = null; } } /* * // Turn on the skeleton stream to receive skeleton frames * this.sensor.SkeletonStream.Enable(); * * // Add an event handler to be called whenever there is new color frame data * this.sensor.SkeletonFrameReady += this.SensorSkeletonFrameReady; * * // Start the sensor! * try * { * this.sensor.Start(); * } * catch (IOException) * { * this.sensor = null; * } * } */ if (null == this.sensor) { this.statusBarText.Text = Properties.Resources.NoKinectReady; } }