Thanks for posting that code…hadn’t seen that snippet before. I’ve been working on multi/single kinect initialization based on a snippet from the openni forum (from round May 2011): http://openni-discussions.979934.n3.nabble.com/OpenNI-dev-Skeleton-tracking-with-multiple-kinects-not-solved-with-new-OpenNI-td2832613.html
The methods are basically the same:
* First init the context -> I’m not sure you can have multiple contexts…I’ll check into it, but I think the idea is that you have one context and multiple devices with multiple “production” nodes (ie., depth, image ir, audio generators)
* Then you enumerate the production tree either a) creating new nodes specified by the user “programmatically” (depth + image would be common, but could also be ir and/or audio) OR b) by executing a nominated XML config – I’ve tended to use the first method but openNI/NITE examples very often do the latter…quite often those examples (and indeed ofxOpenNI/gameoverhack) use a method like your second edit to check the tree for production nodes that already exist…essentially thats what I’m doing when ofxOpenNI starts up and spits out a message like “Looking for Depth Generator. None Found…creating!” but instead of stepping through the tree, the checks are done on initialization (setup) of depth, image, ir etc so that I was able to use the same code in the setup methods regardless of whether init is handled by executing an XML config or whether the nodes are programmatically requested. I think it’s good to support both methods of init’ing a kinect…
I think it would be good to restructure ofxOpenNI to handle methods of enumeration like this…a naming question:
* Should we make ofxOpenNIContext just a wrapper for the context? And create a new “manager” class called ofxONI (as per roxlu) or ofxOpenNIManager or just plain ofxOpenNI? that does all the work of enumerating devices and init’ing depth, ir, image nodes? or just make ofxOpenNIContext do this job? I’m leaning toward using ofxOpenNI (currently just an include .h file) as that should make it easier to not break existing code and looks more symmetric with ofxKinect…
on that note: @danomatika thanks for the links…will look at how you’ve been wrapping things…on the face of it I agree that either the openNI “manager” class should mirror ofxKinect or at the very least we should adopt/create an (extra?) interface class to allow for easier a/b comparisons…would be good to have other ofxKinect/ofxOpenNI “dual” user feedback on these issues…do other people feel strongly that we should mirror the ofxKinect API?
Here are some of my thoughts to open up discussion about sharing API styles:
* the underlying libraries for ofxKinect and ofxOpenNI work in quite different ways…there are going to be some fairly essential differences -> can we really make them interchangeable? And if they don’t completely swap in and out is it worth the time mirroring API style -> not all calls are easily made to work the same way…
* I remember when I was wrapping point cloud and depth pixel stuff that having the same API was going to make some function calls less efficient if I used exactly the same semantics so I couldn’t do it easily
* there are some methods I just plain don’t like the name of (eg., numConnected()) which I guess is no reason not to use them, just that it doesn’t feel in keeping with the overall style of everything else…
* there are a slew of methods ofxOpenNI needs which ofxKinect does not or are more in keeping with the underlying code (for instance openNI call “calibrating” the depth image to the rgb image “registration”, and ofxOpenNI methods reflect this difference in naming (on the basis that searching for help when developing code or looking for other examples using such a feature yield (more?) relevant results)…
* there are a number of methods that ofxKinect could adopt that ofxOpenNI is using (such as multiple depth pixel masks etc)…
@roymacdonald: indeed it looks like you’ve forked from roxlu and then copied in my include, lib and src files over the top of the “roxlu” ones…which is going to be a bit icky for a pull request on roxlu, as my changes become cut off from history and it’s hard to see where you’re code ends and mine begins. Although it’s some work I’m wondering if it would be easier to make a new fork from my repo and then add in your changes to that repo on a new branch called for eg., “feature_autoskeleton” or something like that? Then you could issue the pull against my repo and if you did any copy pasting of code that you’ve altered/corrected in files based on my src these will correctly come up in my fork as alterations to the latest code…