Code Monkey home page Code Monkey logo

Comments (7)

eddiecohen avatar eddiecohen commented on May 20, 2024

Hi,

It is no longer a feature of OpenNI / NiTE.
Having multiple applications that use the same sensor creates a lot of limitations on those applications. Developers of an application should take a lot of considerations when developing such applications (for example, which application will be the "master", being able to choose resolution for example). This means that one can't just develop an application without knowing which other applications might be running in the same time.
For the same reason, webcams can only be accessed by a single application at a time.

If on your specific configuration you want to have two applications running together, your options are:

  • Merge those two application into a single one, or
  • Develop a third application that will be the one accessing the sensor and running NiTE, and have the two original applications read data from it using IPC (sockets/shared memory/etc).

from openni2.

chriskilding avatar chriskilding commented on May 20, 2024

Ah well, time to find a workaround then.

So if both apps are merged into one, somewhere in the Nite-based module there will be a usertracker.create() call, and somewhere in the ONI-based module there will be something that opens up a VideoStream from the device. Will this be allowed to work, because they are both running in the same process (albeit in different threads)? Or will it fail?

from openni2.

tomoto avatar tomoto commented on May 20, 2024

I think you can achieve your goal by the following structure:
(1) Create a depth stream and register a listener to achieve your first goal (in ONI-based module)
(2) Create a user tracker "by passing the depth stream above" to achieve your second goal (in NiTE-based module)

I suppose this configuration allows you to consume the same data from one depth stream by two modules.

from openni2.

eddiecohen avatar eddiecohen commented on May 20, 2024

Actually, User Tracker takes a device, not a depth stream.
And yes, OpenNI architecture allows creating several streams from the same process - the User Tracker object will read depth frames from its stream, and your module will read depth frames from its own stream, without interrupting each other.

One thing to note tough in such a configuration, is that if you need a video mode other than the default one, you should set it to the depth stream before creating the User Tracker.

from openni2.

tomoto avatar tomoto commented on May 20, 2024

Oops, my bad. Thank you for correction.

you should set it to the depth stream before creating the User Tracker.

So, the general programming guideline might be "The application needs to know that the video mode and other sensor properties may be shared between multiple streams of the same type spawned from the same device. The application is responsible for setting them up in the right order without conflict" or something, I suppose.

from openni2.

chriskilding avatar chriskilding commented on May 20, 2024

Okay, I think I got how to do it now.

In the past few days I have wondered if sharing within the same application could be made easier with, say, a ReadOnlyDevice class, which would publicly inherit from Device, and which behaves pretty much the same as a Device, but prevents any setter operations (after initialization) that could cause conflicts - for compatibility maybe it could implement them but throw an exception. There would also need to be a way for a class user to determine the ReadOnlyDevice's current configuration at runtime before registering itself, then, if it's cool with the config, it can proceed, and if not then it can refuse to connect.

from openni2.

eddiecohen avatar eddiecohen commented on May 20, 2024

A couple of comments:

  • From OpenNI point of view, there's no problem in creating multiple streams in the same process. It's the application responsibility to choose the proper configuration for all modules requiring the stream.
  • NiTE has a limitation today - it does not support changing resolution after it was initialized, and that's why it's important to set it before initializing NiTE. This limitation has nothing to do with OpenNI itself. Other middleware libraries, or even future versions of NiTE might not have this limitation.
  • Having a ReadOnlyDevice class will just complicate things. You don't expect your application to won't start on a customer's machine, telling them it couldn't get the configuration it needed, right? Selecting the proper configuration and making sure all 3rd party libraries you use in your application can work with it is part of the development of the application. The application developer is the integrator of all libraries and must make sure a specific configuration works for him. Once such a configuration was found, it is highly suggested that the application actually set the sensor to that configuration explicitly.

from openni2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.