Пример #1
0
        private void initFubi()
        {
            List <string> availableSensors = new List <string>();

            availableSensors.Add(Enum.GetName(typeof(FubiUtils.SensorType), FubiUtils.SensorType.NONE));
            FubiUtils.SensorType type = FubiUtils.SensorType.NONE;
            int avSensors             = Fubi.getAvailableSensors();

            if ((avSensors & (int)FubiUtils.SensorType.OPENNI2) != 0)
            {
                type = FubiUtils.SensorType.OPENNI2;
                availableSensors.Add(Enum.GetName(typeof(FubiUtils.SensorType), type));
            }
            if ((avSensors & (int)FubiUtils.SensorType.KINECTSDK) != 0)
            {
                if (type == FubiUtils.SensorType.NONE)
                {
                    type = FubiUtils.SensorType.KINECTSDK;
                }
                availableSensors.Add(Enum.GetName(typeof(FubiUtils.SensorType), FubiUtils.SensorType.KINECTSDK));
            }
            if ((avSensors & (int)FubiUtils.SensorType.OPENNI1) != 0)
            {
                if (type == FubiUtils.SensorType.NONE)
                {
                    type = FubiUtils.SensorType.OPENNI1;
                }
                availableSensors.Add(Enum.GetName(typeof(FubiUtils.SensorType), FubiUtils.SensorType.OPENNI1));
            }
            string selectedName = Enum.GetName(typeof(FubiUtils.SensorType), type);

            foreach (string sType in availableSensors)
            {
                int index = sensorSelectionComboBox.Items.Add(sType);
                if (index > -1 && sType == selectedName)
                {
                    sensorSelectionComboBox.SelectedIndex = index;
                }
            }
            switchSensorOnNextUpdate = false;

            Fubi.init(new FubiUtils.SensorOptions(new FubiUtils.StreamOptions(640, 480, 30), new FubiUtils.StreamOptions(640, 480), new FubiUtils.StreamOptions(-1, -1, -1), type));
            Fubi.loadRecognizersFromXML("MouseControlRecognizers.xml");
        }
Пример #2
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();
        }
Пример #3
0
 internal static extern bool switchSensor(FubiUtils.SensorType type, int depthWidth, int depthHeight, int depthFPS = 30,
                                          int rgbWidth = 640, int rgbHeight = 480, int rgbFPS = 30,
                                          int irWidth  = -1, int irHeight   = -1, int irFPS   = -1,
                                          FubiUtils.SkeletonProfile profile = FubiUtils.SkeletonProfile.ALL,
                                          [MarshalAs(UnmanagedType.U1)] bool mirrorStream = true, float smoothing = 0);