// Called on deactivation void OnDestroy() { if (this == instance) { Fubi.release(); Debug.Log("Fubi released!"); } }
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(); }
private void releaseFubi() { Fubi.release(); }