0

Our project is (http://www.play4health.com/p4h_eng/) using Ogre 3D over Ubuntu 11.04. Except for core services all is based in a plugin architecture taking advantage of Ogre 3d plugin facilities.

In our plugin architecture plugins can be:

  • Videogames
  • Interaction methods

Users configure their session creating tuples (videogame, interaction method). The flow is a session is: * User load his session. * User click of one of the tuples for the session and play to videogame with a specific interaction method. * Repeat it until end all activities of the session.

Plugin are loaded/unloaded dynamically by demand.

One of this interaction methods is hand tracking using openni. What is the problem? * Fist time that openni plugin is loading all work perfectly. * Next time that plugin openni has to be loaded system is able to detect gestures but not do hand tracking. Note that all plugin are executed in the same process. Right now only solution is to reboot platform.

This is the code for init and release OpenNI in our plugin

  bool IPKinectPlugin::onInitialise()
  {
    mHandPointer.mId = "KinectHandPointer";
    mHandPointer.mHasAbsolute = true;
    mHandPointer.mHasRelative = false;

    XnStatus nRetVal = XN_STATUS_OK;

    nRetVal = gContext.InitFromXmlFile(String(this->getPluginInfo()-
  >getResPath() + "SamplesConfig.xml").c_str());
    CHECK_RC(nRetVal, bContext, "InitFromXml");

  #if SHOW_DEPTH
    nRetVal = gContext.FindExistingNode(XN_NODE_TYPE_DEPTH,gDepthGenerator);
    bDepthGenerator = (nRetVal != XN_STATUS_OK);
    if (bDepthGenerator)
    {
    nRetVal = gDepthGenerator.Create(gContext);
    CHECK_RC(nRetVal, bDepthGenerator, "Find Depth generator");
    }
  #endif


    nRetVal = gContext.FindExistingNode(XN_NODE_TYPE_USER, gUserGenerator);
    bUserGenerator = (nRetVal != XN_STATUS_OK);
    if (/*bUserGenerator*/false)
    {
    nRetVal = gUserGenerator.Create(gContext);
    CHECK_RC(nRetVal, bUserGenerator, "Find user generator");
    }

    nRetVal = gContext.FindExistingNode(XN_NODE_TYPE_GESTURE, gGestureGenerator);
    bGestureGenerator = (nRetVal != XN_STATUS_OK);
    if (bGestureGenerator)
    {
    nRetVal = gGestureGenerator.Create(gContext);
    CHECK_RC(nRetVal, bGestureGenerator, "Find gesture generator");

    XnCallbackHandle hGestureCallbacks;
    gGestureGenerator.RegisterGestureCallbacks(gestureRecognized, gestureProcess, 0,
        hGestureCallbacks);
    }

    nRetVal = gContext.FindExistingNode(XN_NODE_TYPE_HANDS,gHandsGenerator);
    bHandsGenerator = (nRetVal != XN_STATUS_OK);
    if (bHandsGenerator)
    {
    nRetVal = gHandsGenerator.Create(gContext);
    CHECK_RC(nRetVal, bHandsGenerator, "Find hands generator");

    XnCallbackHandle hHandsCallbacks;
    gHandsGenerator.RegisterHandCallbacks(handsNew, handsMove,handsLost, 0, hHandsCallbacks);
    }

    nRetVal = gContext.FindExistingNode(XN_NODE_TYPE_DEVICE, gDevice);
    bDevice = (nRetVal != XN_STATUS_OK);

    gContext.RegisterToErrorStateChange(onErrorStateChanged, NULL, hDummyCallbackHandle);

    //Preparo la textura para la webcam
    if (bGenerateRGBTexture)
    mWebcamTexture = KinectTools::createDepthTexture("KinectWebCamTexture", sPluginName);

    return true;
  }
  //-----------------------------------------------------------------------------

  bool IPKinectPlugin::onShutdown()
  {
    if (bContext)
    {
    if (bHandsGenerator)
    {
        gHandsGenerator.StopTrackingAll();
    }
    if (bGestureGenerator)
    {
        gGestureGenerator.RemoveGesture(GESTURE_TO_USE);
        gGestureGenerator.RemoveGesture(GESTURE_TO_START);
    }
    gContext.StopGeneratingAll();
    gContext.Shutdown();
    }

    return true;
  }

Any idea about this issue? Any wrong with this code?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
user560500
  • 21
  • 3

1 Answers1

0

Maybe you already found a solution in the meantime...

I normally work with the Java Wrapper, but what I see as difference to my code is that I call contect.startGeneratingAll() after creating the generators (Depth, Hands and so on). I had also problems when I did this multiple times at start up. Another difference is that I use a context.release at shutdown.

My procedure is normally:

  • Init config (License, Nodes, settings)
  • Create generators
  • Start Generating All
  • Run your code ...
  • Stop Generating ALL
  • Context release

From OpenNI Documentation

XN_C_API void XN_C_DECL xnShutdown ( XnContext * pContext )

Shuts down an OpenNI context, destroying all its nodes. Do not call any function of this context or any correlated node after calling this method. NOTE: this function destroys the context and all the nodes it holds and so should be used very carefully. Normally you should just call xnContextRelease()

FSaccilotto
  • 656
  • 8
  • 13