示例#1
0
        public void Start_Recording(object sender, System.EventArgs e)
        {
            sessionName = DateTime.Now.ToString("yyyy-MM-dd-") + DateTime.Now.Hour.ToString() + "H" + DateTime.Now.Minute.ToString() + "M" + DateTime.Now.Second.ToString() + "S";

            isRecording = true;
            isRecordingLabel.Content = "Recording...";

            // if session folder doesn't exists, it creates it
            System.IO.Directory.CreateDirectory(sessionPath + sessionName + "/");

            myScreenCapture = new ScreenCapture();
            myScreenCapture.captureStart(sessionPath + sessionName);
            myMyoViewModel = new MyoViewModel();
            myMyoViewModel.ValuesChanged += MyMyoViewModel_ValuesChanged;

            startRecordingTime = DateTime.Now;

            myMyoRecordingObject = new RecordingObject
            {
                RecordingID     = startRecordingTime.ToString("yyyy-MM-dd-HH-mm-sss"),
                ApplicationName = "Myo"
            };
            myKinectRecordingObject = new RecordingObject
            {
                RecordingID     = startRecordingTime.ToString("yyyy-MM-dd-HH-mm-sss"),
                ApplicationName = "Kinect"
            };
            //myoChunk = new RecordingObject
            //{
            //    RecordingID = startChunkTime.ToString("yyyy-MM-dd-HH-mm-sss"),
            //    ApplicationName = "Myo"
            //};
            feedbackObject = new RecordingObject
            {
                RecordingID     = startRecordingTime.ToString("yyyy-MM-dd-HH-mm-sss"),
                ApplicationName = "Feedback"
            };
            detectedCompressions = new AnnotationObject
            {
                RecordingID     = startRecordingTime.ToString("yyyy-MM-dd-HH-mm-sss"),
                ApplicationName = "CPRTutor_annotations"
            };

            targetList = new Dictionary <string, List <int> >();

            setValueNames();
            CreateSockets();
        }
示例#2
0
        public void setKinectValues(Body[] bodies)
        {
            if (isRecording)
            {
                int           counter = 0;
                List <string> values  = new List <string>();
                KinectValues = new List <string>();
                foreach (Body body in bodies)
                {
                    try
                    {
                        if (body.IsTracked)
                        {
                            detectCompression(body.Joints[JointType.ShoulderRight].Position.Y);
                            KinectValues.Add(body.Joints[JointType.AnkleRight].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.AnkleRight].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.AnkleRight].Position.Z + "");

                            KinectValues.Add(body.Joints[JointType.AnkleLeft].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.AnkleLeft].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.AnkleLeft].Position.Z + "");

                            KinectValues.Add(body.Joints[JointType.ElbowRight].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.ElbowRight].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.ElbowRight].Position.Z + "");

                            KinectValues.Add(body.Joints[JointType.ElbowLeft].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.ElbowLeft].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.ElbowLeft].Position.Z + "");

                            KinectValues.Add(body.Joints[JointType.HandRight].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.HandRight].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.HandRight].Position.Z + "");

                            KinectValues.Add(body.Joints[JointType.HandLeft].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.HandLeft].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.HandLeft].Position.Z + "");

                            KinectValues.Add(body.Joints[JointType.HandTipRight].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.HandTipRight].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.HandTipRight].Position.Z + "");

                            KinectValues.Add(body.Joints[JointType.HandTipLeft].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.HandTipLeft].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.HandTipLeft].Position.Z + "");

                            KinectValues.Add(body.Joints[JointType.Head].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.Head].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.Head].Position.Z + "");

                            KinectValues.Add(body.Joints[JointType.HipRight].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.HipRight].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.HipRight].Position.Z + "");

                            KinectValues.Add(body.Joints[JointType.HipLeft].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.HipLeft].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.HipLeft].Position.Z + "");

                            KinectValues.Add(body.Joints[JointType.ShoulderRight].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.ShoulderRight].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.ShoulderRight].Position.Z + "");

                            KinectValues.Add(body.Joints[JointType.ShoulderLeft].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.ShoulderLeft].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.ShoulderLeft].Position.Z + "");

                            KinectValues.Add(body.Joints[JointType.SpineMid].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.SpineMid].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.SpineMid].Position.Z + "");

                            KinectValues.Add(body.Joints[JointType.SpineShoulder].Position.X + "");
                            KinectValues.Add(body.Joints[JointType.SpineShoulder].Position.Y + "");
                            KinectValues.Add(body.Joints[JointType.SpineShoulder].Position.Z + "");
                            KinectValues.Add(volumeHandler.averageVolume.ToString());

                            if (body.Joints[JointType.ShoulderRight].Position.X != 0)
                            {
                                int xxx = counter;
                            }

                            var update = new FrameObject(startRecordingTime, kinectNames, KinectValues);
                            myKinectRecordingObject.Frames.Add(update);


                            if (compressionCounter > previousKinectCompressionCounter)
                            {
                                sendingData = true;
                                // NEW LINES of CODE

                                Thread thread = new Thread(new ThreadStart(sendChunk));
                                thread.Start();

                                //end of new lines of code

                                //sendChunk(); //I just changed this uncomment this line in case the new solution does not work

                                //String responseData;
                                startChunkTime = DateTime.Now;
                                myoChunk       = new RecordingObject
                                {
                                    RecordingID     = startChunkTime.ToString("yyyy-MM-dd-HH-mm-sss"),
                                    ApplicationName = "Myo"
                                };
                                kinectChunk = new RecordingObject
                                {
                                    RecordingID     = startChunkTime.ToString("yyyy-MM-dd-HH-mm-sss"),
                                    ApplicationName = "Kinect"
                                };



                                previousKinectCompressionCounter = compressionCounter;

                                //string gaugeImage = @"C:\Users\Daniele-WIN10\Documents\GitHub\SharpFlow\gauge.png";
                                //if (File.Exists(gaugeImage))
                                //{
                                //    BitmapImage image = new BitmapImage();
                                //    image.BeginInit();
                                //    image.CacheOption = BitmapCacheOption.OnLoad;
                                //    image.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
                                //    image.UriSource = new Uri(gaugeImage);
                                //    image.EndInit();
                                //    cprGauge.Source = image;
                                //    cprGauge.Width = 500;

                                //}
                            }
                            var newKinectChunk = new FrameObject(startChunkTime, kinectNames, KinectValues);
                            kinectChunk.Frames.Add(newKinectChunk);
                            //Console.WriteLine("Addded new kinectChunk: {0}", newKinectChunk.ToString());
                        }
                    }
                    catch
                    {
                    }
                    counter++;
                }
            }
        }