Esempio n. 1
0
        private void fubiMain(object filterOptions)
        {
            m_renderOptions  = 0;
            m_renderOptions |= (int)FubiUtils.RenderOptions.Shapes;
            //m_renderOptions |= (int)FubiUtils.RenderOptions.Skeletons;
            //m_renderOptions |= (int)FubiUtils.RenderOptions.UserCaptions;
            //m_renderOptions |= (int)FubiUtils.RenderOptions.Background;
            //m_renderOptions |= (int)FubiUtils.RenderOptions.SwapRAndB;
            // m_renderOptions |= (int)FubiUtils.RenderOptions.DetailedFaceShapes;
            //m_renderOptions |= (int)FubiUtils.RenderOptions.BodyMeasurements;
            // m_renderOptions |= (int)FubiUtils.RenderOptions.GlobalOrientCaptions; // or
            //m_renderOptions |= (int)FubiUtils.RenderOptions.LocalOrientCaptions;
            // m_renderOptions |= (int)FubiUtils.RenderOptions.GlobalPosCaptions;  // or
            //m_renderOptions |= (int)FubiUtils.RenderOptions.LocalPosCaptions;
            m_renderOptions |= (int)FubiUtils.RenderOptions.UseFilteredValues;

            var rgbOptions     = new FubiUtils.StreamOptions();
            var irOptions      = new FubiUtils.StreamOptions();
            var depthOptions   = new FubiUtils.StreamOptions();
            var invalidOptions = new FubiUtils.StreamOptions(-1);

            lock (LockFubiUpdate)
            {
                if (!Fubi.init(new FubiUtils.SensorOptions(depthOptions, rgbOptions, irOptions, m_selectedSensor),
                               (FubiUtils.FilterOptions)filterOptions))
                {   // the following for when the init fails
                    m_selectedSensor = FubiUtils.SensorType.NONE;
                    Fubi.init(new FubiUtils.SensorOptions(depthOptions, invalidOptions, invalidOptions, m_selectedSensor),
                              (FubiUtils.FilterOptions)filterOptions);
                    Dispatcher.BeginInvoke(new TwoStringDelegate(showWarnMsg),
                                           new object[]
                    {
                        "Error starting sensor! \nDid you connect the sensor and install the correct driver? \nTry selecting a different sensor.",
                        "Error starting sensor"
                    });
                    return;
                }
                Fubi.getDepthResolution(out m_width, out m_height);
                m_numChannels = FubiUtils.ImageNumChannels.C4;

                // All known combination recognizers will be started automatically for new users
                Fubi.setAutoStartCombinationRecognition(true);

                // Load XML with sample mouse control gestures
                if (Fubi.loadRecognizersFromXML("TutorialRecognizers.xml"))
                {
                    //    // This requires to update the gesture list used for selecting key/button bindings and for xml generation
                    //    Dispatcher.BeginInvoke(new NoArgDelegate(refreshGestureList), null);
                    //    // Now we can load the default bindings using the above recognizers
                    //    Dispatcher.BeginInvoke(new OneStringDelegate(m_fubiMouseKeyboard.Bindings.loadFromXML), "KeyMouseBindings.xml");
                }
            }

            Fubi.RecognitionStart += new Fubi.RecognitionHandler(recognitionStart);
            Fubi.RecognitionEnd   += new Fubi.RecognitionHandler(recognitionEnd);
            DispatcherOperation currentOp = null;

            videoFile.fileName = "trainingData/tempRecord2.vid";
            videoFile.startPlayback();

            while (m_running)
            {
                lock (LockFubiUpdate)
                {
                    // Now update the sensors
                    Fubi.updateSensor();

                    Fubi.getImage(s_buffer2, FubiUtils.ImageType.Depth, m_numChannels, FubiUtils.ImageDepth.D8, m_renderOptions,
                                  (int)FubiUtils.JointsToRender.ALL_JOINTS, m_selectedDepthMod);
                }

                // And trigger a GUI update event
                currentOp = Dispatcher.BeginInvoke(new NoArgDelegate(updateGUI), null);
                // Wait for the GUI update to finish
                while (currentOp.Status != DispatcherOperationStatus.Completed &&
                       currentOp.Status != DispatcherOperationStatus.Aborted)
                {
                    Thread.Sleep(5);
                }
            }
            // Wait for the last GUI update to really have finished
            while (currentOp != null && currentOp.Status != DispatcherOperationStatus.Completed &&
                   currentOp.Status != DispatcherOperationStatus.Aborted)
            {
                Thread.Sleep(2);
            }
            // Now we can release Fubi safely
            Fubi.release();
        }
Esempio n. 2
0
        private void setProgress(int stage)
        {
            activeGestures.Clear();
            gameStage = stage;
            stageTime = DateTime.Now;
            if (videoPlaying)
            {
                maleSpiderVideo.Stop();
            }
            string fid = System.IO.Path.Combine(mediaPath, maleSpiderVideos[gameStage]);

            if (File.Exists(fid))
            {
                maleSpiderVideo.Source   = new System.Uri(fid);
                videoPlaying             = false; // will wait for fubi thread cycle before starting
                videoStatsLbl.Visibility = Visibility.Hidden;
            }
            else
            {
                videoStatsLbl.Content    = fid;
                videoStatsLbl.Visibility = Visibility.Visible;
            }
            System.Windows.Controls.Label[] stageLabels = { progressLbl1, progressLbl2, progressLbl3, progressLbl4, progressLbl5, progressLbl6, progressLbl7, progressLbl8 };
            for (int i = 0; i < stageLabels.Length; i++)
            {
                if (i == stage)
                {
                    stageLabels[i].Foreground = Brushes.Yellow;
                    stageLabels[i].Background = Brushes.Green;
                }
                else
                {
                    stageLabels[i].Foreground = Brushes.Brown;
                    stageLabels[i].Background = Brushes.Gray;
                }
                stageLabels[i].FontSize = 32;
            }
            if (stage == 7)
            {
                statusLbl.Content    = "SUCCESS! SHE LOVES MY DANCE.";
                statusLbl.Visibility = Visibility.Visible;
            }
            else if (stage == 8)
            {
                statusLbl.Content    = "FAILURE. RUN AWAY!";
                statusLbl.Visibility = Visibility.Visible;
            }
            else
            {
                statusLbl.Visibility = Visibility.Hidden;
            }

            videoFile.stopPlay();
            if (gameStage <= gameStageVideos.Length)
            {
                videoFile.fileName = System.IO.Path.Combine(spiderDancePath, gameStageVideos[gameStage]);
                guideLbl.Content   = videoFile.fileName;
                if (File.Exists(videoFile.fileName))
                {
                    videoFile.startPlayback();
                    guideLbl.Visibility = Visibility.Hidden;
                }
                else
                {
                    guideLbl.Visibility = Visibility.Visible;
                }
            }
            TimeOutBar.Width = 0;
        }