private KinectSensor sensor; // used in both! #endregion Fields #region Constructors public ExerciseScreen(PrescribedExercise pe) { /*KinectSensorAdapter.Instance.DiscoverKinectSensor(); //KinectSensorAdapter.Instance.RegisterCallbacks(FrameReady, ValidSkeletonReady, InValidSkeletonRecognized); KinectSensorAdapter.Instance.SubscribeForKinectBitmapReady(BitmapReady); //KinectSensorAdapter.Instance.SubscribeForKinectColorArrayReady(FrameReady); KinectSensorAdapter.Instance.SubscribeForKinectValidSkeletonReady(ValidSkeletonReady); KinectSensorAdapter.Instance.SubscribeForKinectInValidSkeletonRecognized(InValidSkeletonRecognized); KinectSensorAdapter.Instance.SubscribeForKinectStatusUpdates(KinectStatusChanged); //KinectSensorAdapter.Instance.RegisterCallbacks(this.ColorImageFrameReady,this.ValidSkeletonReady,this.InValidSkeletonRecognized);*/ InitializeComponent(); progressBar1.Maximum = pe.number_of_repitions; //exerciseName_label.Content = pe.prescribed_exercise.name_of_exercise; Console.Write("Window Loaded"); foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { this.sensor = potentialSensor; break; } } if (null != this.sensor) { // Turn on the color stream to receive color frames this.sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); // Allocate space to put the pixels we'll receive this.colorPixels = new byte[this.sensor.ColorStream.FramePixelDataLength]; // This is the bitmap we'll display on-screen this.colorBitmap = new WriteableBitmap(this.sensor.ColorStream.FrameWidth, this.sensor.ColorStream.FrameHeight, 96.0, 96.0, PixelFormats.Bgr32, null); // Set the image we display to point to the bitmap where we'll put the image data KinectVideoFeed_Box.Source = this.colorBitmap; // Add an event handler to be called whenever there is new color frame data this.sensor.ColorFrameReady += this.SensorColorFrameReady; // Start the sensor! try { this.sensor.Start(); } catch (IOException) { this.sensor = null; } } if (null == this.sensor) { //MessageBox.Show("Please connect a Kinect"); } // 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 image1.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) { // 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; } }
public void add(PrescribedExercise pe) { prescription.Add(pe); }