Example #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (KinectSensor.KinectSensors.Count > 0)
            {
                this.sensor = KinectSensor.KinectSensors[0];

                if (this.sensor.Status == KinectStatus.Connected)
                {
                    Image[] codes = new Image[] { _0_code, _1_code, _2_code, _3_code, _4_code, };
                    foreach (Image i in codes)
                    {
                        i.Visibility = Visibility.Hidden;
                    }
                    _0_code.Visibility = Visibility.Visible;
                    calController      = new CalibrationController(sensor, kinectController, drawingCanvas, codes, image1);
                    calController.CalibrationDidComplete += new CalibrationController.calibrationDidCompleteHandler(calibrationCompleted);
                    //sensor.AllFramesReady += kinectController.SensorAllFramesReady;
                    //calibrationCompleted();

                    this.sensor.AllFramesReady += calController.DisplayColorImageAllFramesReady;
                    this.sensor.ColorStream.Enable();
                    this.sensor.DepthStream.Enable();
                    //this.sensor.ColorStream.CameraSettings.Contrast = 2.0;

                    Console.WriteLine("abc");

                    this.sensor.Start();
                }
            }

            this.KeyDown          += new KeyEventHandler(OnKeyDown);
            this.MouseDown        += new MouseButtonEventHandler(OnClick);
            this.MouseDoubleClick += new MouseButtonEventHandler(OnDoubleClick);
            soundController.StartMusic();
            drawController.ChangeBackground();
            drawController.ChangeColor(Colors.Red);

            foreach (Ellipse ellipse in buttons)
            {
                ellipse.Visibility = Visibility.Hidden;
            }
        }
        public void SensorAllFramesReady(object sender, AllFramesReadyEventArgs e)
        {
            // Check if we need to change background
            if (drawController.backgroundAlreadySet == false)
            {
                drawController.ChangeBackground(drawController.background);
            }

            // Check if we need to change color
            if (drawController.shouldChangeColor != -1)
            {
                drawController.ChangeColor((Colors)drawController.shouldChangeColor);
            }

            using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
            {
                if (depthFrame != null)
                {
                    this.ParseDepthFrame(depthFrame);
                }
            }
        }