예제 #1
0
        private void Reader_MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e)
        {
            var mSourceFrame = e.FrameReference.AcquireFrame();

            // If the Frame has expired by the time we process this event, return.
            if (mSourceFrame == null)
            {
                return;
            }

            DepthFrame depthFrame = null;
            ColorFrame colorFrame = mSourceFrame.ColorFrameReference.AcquireFrame();

            using (colorFrame)
            {
                if (colorFrame != null)
                {
                    cameraIMG.Source = KinectExtensions.ToBitmap(colorFrame);
                    colorFrame.CopyConvertedFrameDataToArray(lastNotNullColorData, ColorImageFormat.Bgra);

                    (Parent as MainWindow).PlaygroundWindow.ShowImage(cameraIMG.Source);
                }

                try
                {
                    depthFrame = mSourceFrame.DepthFrameReference.AcquireFrame();
                    if (depthFrame != null)
                    {
                        // Access the depth frame data directly via LockImageBuffer to avoid making a copy
                        using (KinectBuffer depthFrameData = depthFrame.LockImageBuffer())
                        {
                            kinectSensor.CoordinateMapper.MapColorFrameToDepthSpaceUsingIntPtr(
                                depthFrameData.UnderlyingBuffer,
                                depthFrameData.Size,
                                colorMappedToDepthSpace);

                            depthFrame.CopyFrameDataToArray(lastNotNullDepthData);
                        }
                        // We're done with the DepthFrame
                        depthFrame.Dispose();
                        depthFrame = null;
                    }
                }
                finally
                {
                    if (depthFrame != null)
                    {
                        depthFrame.Dispose();
                    }

                    if (colorFrame != null)
                    {
                        colorFrame.Dispose();
                    }
                }
            }
        }
예제 #2
0
        public void Initialize()
        {
            Container.RegisterType <IKinectUiService, KinectUiService>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IKinectUiElementController, KinectUiElementController>();
            var kinectUiService = Container.Resolve <IKinectUiService>();

            try
            {
                Container.RegisterInstance <KinectSensor>(KinectExtensions.GetDefaultKinectSensor());
            }
            catch (KinectNotFoundException ex)
            {
                //TODO: Handle exception
            }
        }
예제 #3
0
 public void Initialize()
 {
     lock (isInitializedSync)
     {
         if (IsInitialized)
         {
             return;
         }
         applicationName = Container.IsRegistered <String>(GlobalInstanceNames.ApplicationName) ? Container.Resolve <String>(GlobalInstanceNames.ApplicationName) : String.Empty;
         KinectSensor sensor = KinectExtensions.GetDefaultKinectSensor();
         sensor.EnsureStart();
         this.audioSource      = sensor.GetKinectAudioSource();
         this.speechRecognizer = this.GetKinectSpeechRecognizer();
         IsInitialized         = true;
     }
 }