コード例 #1
0
ファイル: Controller.cs プロジェクト: togores/Vitruvius
        /// <summary>
        /// Thread que faz o processamento.
        /// </summary>
        private void WorkerThread(object sender, EventArgs e)
        {
            // atualiza os dados dos dispositivos
            try {
                context.WaitAnyUpdateAll();
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }

            #region Drawing

            if (drawRGBImage)
            {
                rgbCamera.UpdateMetadata();
                rgbImage.DrawFrame(rgbCamera, userManager);
            }
            else if (drawDepthImage)
            {
                depthSensor.UpdateMetadata();
                depthSensor.UpdateHistogram();
                depthImage.DrawFrame(depthSensor, userManager);
            }
            else
            {
                DeviceImage.DrawFrame();
            }
            // desenha
            WindowManager.MainWindow.image.Source = DeviceImage.WriteableBitmap;

            #endregion

            // atualiza os usuários
            userManager.UpdateAllUsers();
            mainUser = userManager.UpdateMainUser();
            windowManager.MainWindow.usersLabel.Text = userManager.GetUsersLabel();
            lock (this) {
                if (realtime)
                {
                    recorder.Capture(mainUser, userManager.Skeleton);
                    observer.Capture(mainUser);
                }
            }

            // calcula o fps do programa
            DateTime now        = DateTime.Now;
            double   timePassed = 0.0;
            timePassed += now.Millisecond + 1000 * (now.Second + 60 * (now.Minute + 60 * now.Hour));
            timePassed -= time.Millisecond + 1000 * (time.Second + 60 * (time.Minute + 60 * time.Hour));
            time        = now;
            windowManager.MainWindow.fpsTextBlock.Text = (int)(1000 / timePassed) + " FPS";
        }