OpenNI Skeleton Tracking

how do i get a completely transparent video feed after tracking and masking? currently i get black areas instead of transparency.

i’ve tried
glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);
and
glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA);

with no luck.

thanks.
alp

@ungaro:

It’s in my example; you want:

  
glBlendFunc(GL_DST_COLOR, GL_ZERO)  

perhaps?

@gameover tnx for great work with ofxXmlSettings! I know its not a permanent solution, but important is that it works :slight_smile:

@gameover:

yeah, but i get black pixels instead of transparency.

what i want to do is, have a static background image, and get user body overlaid on the background.

maybe i’m doing it in a wrong way.

i’ve loaded a background image with
ofImage background;
background.loadImage(“lala.jpg”);

and overlaid the video.

it shows black pixels.

thanks,
alp

@ungaro

Masks are always black pixels in the world of openGL

basically you do something like this:

  
background.draw(0,0);  
glEnable(GL_BLEND);  
glBlendFunc(GL_DST_COLOR, GL_ZERO);  
mask.draw(0, 0);  
glDisable(GL_BLEND);  
  

perhaps post some code you are using?

again, it’s all in the example…

…and on that note:

I’ve updated my version of ofxOpenNI and merged all branches to the same point. Again, from now on I’ll hack away at ‘experimental’…

It’s at https://github.com/gameoverhack/ofxOpenNI

Changes include:

* changed how image, depth, recorder and user generators are instantiated - sorry it’s gonna break code, but makes life easier…you now only pass a reference to the context you are using…;
# added infra red generators -> works with all functions including record…;
* fixed initializing from xml and added direct initialization from code (no reliance on xml config files at all);
* getDepthPixels (in a range) directly from the depth mask (a la ofxKinect) for when your needing masks, etc that are not openNI ‘User’ shaped;
* getMaskPixels now works correctly, and implements many (all?) of the changes suggested by Chris; you can just grab the pixels of all masks, or set a flag and get separate masks for each user -> note that the old version was not actually getting seperate masks correctly at all…I used a trick I saw ascorbin using in this thread http://forum.openframeworks.cc/t/openni-||-kinect-getuserpixels/5510/0, and implemented it (so many thanks, ascorbin!!);
* completely changed the cloud point drawing method and made it a little more like ofxKinect…still not entirely happy, but hey…it also works a bit like getMaskPixels in that you set a flag and can then retrieve all the cloud points or just a cloud point for each user…;
* updated the example to show the changes…;
* other stuff I forgot :wink:

Mostly I tested this on Mac, but made sure it still compiles on PC -> looked a bit like the cloud and mask stuff was running slowly on PC, so need to investigate…

Some feedback at this point on etiquette and style would be good:

I’m getting further and further away from roxlu and halfdan’s code here…do I keep the project named the same thing? do i put my own licensing/author ref with notes to the original authors? do i go ahead and completely change the way the code is structured? I’m thinking about making the whole way generators are added and updated and drawn quite different and a bit more ‘Manager’ style, ie (psuedo code):

  
ofxOpenNIManager kinect;  
kinect.setup();  
kinect.addDepthGenerator();  
kinect.addImageGenerator(OFX_OPENNI_RGB);  
kinect.addRecord(OFX_ONI_STREAMING);  
  
...  
  
kinect.update();  
someImage.setFromPixels(kinect.getMaskPixels(), w, h, OF_GREYSCALE_IMAGE);  
...  
  
kinect.drawDebug(0,0);  
kinect.drawImage(0,1680,1920,1080);  
  
etc etc;  

But not sure if this is the right way to go…

Feedback most welcome…

M

@gameover
I just used you library and I like it thanks, but it just using user tracking lib and this is a good start. So, do you will make the NITE lib which has the Gestures, Wave, Raise hand on head, and slide functionalities?

On the other hand, did you make a brief documentation for your current library (ofxopenni)?

Cheers :smiley:

I’m trying to have ofxOpenNI working on linux.
I’m on Ubuntu 10.04 on amd64 system, with OF 062, codeblocks and last gameover ofxOpenNI
I can compile the example just fine, but at runtime I get:

  
======              ===                   
PrimeSense          0KOIk2JeIBYClPWVnMoRKn5cdY4=  
Set console output status: OK  
Set log level status: OK  
   13924        [INFO]  OpenNI version is 1.0.0 (Build 25)-Linux-x86 (Mar 18 2011 08:46:37)  
Retrieving depth generator failed: No match found  
   14158        [INFO]  USB is initialized.  
   21044        [INFO]  Creating node 'Device1' of type Device...  
 1470484        [INFO]  Property Device.ShareMode was changed to 1.  
 1470543        [INFO]  Property Device.InstancePointer was changed.  
 1470638        [INFO]  Property Device.ShareMode was changed to 0.  
 1471058        [INFO]  Creating node 'Depth1' of type Depth...  
 1484590        [INFO]  Property Device.ReadData was changed to 1.  
 1502840        [INFO]  Creating stream 'Depth1' of type 'Depth'...  
 1503193        [INFO]  Property Depth1.RequiredDataSize was changed to 153600.  
 1503667        [INFO]  Property Depth1.OutputFormat was changed to 1.  
 1503729        [INFO]  Stream 'Depth1' was initialized.  
 1503750        [INFO]  'Depth1' stream was created.  
Segmentation fault  
  
Process returned 139 (0x8B)   execution time : 1.658 s  

any idea, hint or tip?

best to all, francesco

Sorry: my fault, I was not linking correctly. now it works, a bit erratically but must be my usb interface

[quote author=“hv_francesco”]I’m trying to have ofxOpenNI working on linux.
I’m on Ubuntu 10.04 on amd64 system, with OF 062, codeblocks and last gameover ofxOpenNI
I can compile the example just fine, but at runtime I get:

  
======              ===                   
PrimeSense          0KOIk2JeIBYClPWVnMoRKn5cdY4=  
Set console output status: OK  
Set log level status: OK  
   13924        [INFO]  OpenNI version is 1.0.0 (Build 25)-Linux-x86 (Mar 18 2011 08:46:37)  
Retrieving depth generator failed: No match found  
   14158        [INFO]  USB is initialized.  
   21044        [INFO]  Creating node 'Device1' of type Device...  
 1470484        [INFO]  Property Device.ShareMode was changed to 1.  
 1470543        [INFO]  Property Device.InstancePointer was changed.  
 1470638        [INFO]  Property Device.ShareMode was changed to 0.  
 1471058        [INFO]  Creating node 'Depth1' of type Depth...  
 1484590        [INFO]  Property Device.ReadData was changed to 1.  
 1502840        [INFO]  Creating stream 'Depth1' of type 'Depth'...  
 1503193        [INFO]  Property Depth1.RequiredDataSize was changed to 153600.  
 1503667        [INFO]  Property Depth1.OutputFormat was changed to 1.  
 1503729        [INFO]  Stream 'Depth1' was initialized.  
 1503750        [INFO]  'Depth1' stream was created.  
Segmentation fault  
  
Process returned 139 (0x8B)   execution time : 1.658 s  

any idea, hint or tip?

best to all, francesco[/quote]

@gameover

now I was able to run you ofxOpenNI on Ubuntu Linux 10.04, both with 062 and 007,
but I have problems with this part of code in ofxOpenNIContext.cpp:

  
 //Toggle registering view point to image map  
	if (depth_generator.IsCapabilitySupported(XN_CAPABILITY_ALTERNATIVE_VIEW_POINT))  
	{  
  
		if(depth_generator.GetAlternativeViewPointCap().IsViewPointAs(image_generator)) {  
			unregisterViewport();  
		} else {  
			registerViewport();  
		}  
  
	} else return false;  

This seems to be rather CPU intensive, and my double core system is stressed.
if I keep it like this, users are continuosly lost soon after being detected. the mask is right until the user is lost, but it lasts a few seconds and you never achieve a skeleton tracking before loosing the user.
If I comment out the above code, all works perfectly with user detection, and all is stable, but the user masks are obviously offset.
Maybe a not-so-brilliant usb bandwidth has something to do as well, or libusb version, though I’ve tried with last dev version, with no effects.
Any tip about how to fix it?

Hello!

I picked ascorbin’s Gesture Generator code and made a proper ofxGestureGenerator.
It is an incredibly simple hand tracking, just raise your hand and voila!

I just merged it with gameoverhack’s master branch, so It has everything up-to-date.

It’s all on my git fork:
https://github.com/rsodre/ofxOpenNI

note 1) I had to substitute gameoverhack’s automatic context setup() without XML for the good old setupUsingXMLFile(). The auto setup() was detecting hands but not updating.

note 2) The player is not tracking hands properly, I think it has something to do with the context initialization, because it behaves just like the simple setup(), the hand is detected but not tracked.

note 3) For now it only tracks one hand. Tracking more hands became a challenge I have no time to focus right now. If you want to help, take a look on my notes on ofxGestureGenerator.h. But the code is ready for more.

note 4) If you are updating old projects, please note that the depthGenerator now needs explicit update(). Look at the example.

Cheers!
Roger

yey! :lol:

Thanks rsodre & ascorbin!!

Ok so I’ve made a bunch more changes including merging rsodre/ascorbin gesture/hand tracking…

To begin with:

* I’ve successfully recompiled the openNI, SensorKinect and NITE dylibs so that there external reliances on libJPEG and tinyXML are now internally compiled -> this means **no more conflicts with ofxXMLSettings!!! **I compiled against latest unstable from the openNI, NITE and avin’s SensorKinect git repositories…I also made the libusb.dylib portable as this way just about any mac should be able to run our apps with no driver installs…would be great if those trying to get this working on linux try these new drivers (or did you guys have to compile others?)

@hv_francesco: you shouldn’t need to comment out any code, the toggleRegisterViewpoint function is called from inside the testApp -> I’ve added a key ‘r’ for toggling registering so perhaps try that a few times and report back -> seems strange that it should muddle with user detection…hmmm

And then:

* It seems roger and I were working in parallel on incorporating ascorbin’s handtracking example…I realised half way through that an ofxGestureGenerator class should actually only be about recognising gestures and NOT about hand tracking (which rather requires a focus gesture to trigger the beginning of tracking), so I started to do the abstraction/seperation…I’m not sure which way is better…so

…for the purposes of testing I now have three different (working) versions of ofxopenNI on my git repository:

master : no gesture or hand tracking (just updated newly compile libs)

develop : merge of our methods for ofxHandGenerator + multiple hands working (no events for gestures)

experimental : merge and then separation into ofxHandGenerator and ofxGestureGenerator (using ofEvents) + multiple hands working + more smoothing options (both openni and custom)

EDIT: I’ve merged across branches now -> using the experimental approach above with separation of gestures and handtracking and added motor, led, accel control as per below…

* Multiple hands are now working in both the develop and experimental versions -> you’ll notice that the RaiseArm focus gesture triggers a lot and the best way to get fast recognition of a second (or nth) hand is to make sure you lower the hand that has just been recognised and then raise the other hand…

* Also merged a bunch of Roger’s changes to depth texture drawing, getting pixel colors and a few other things I’ve forgotten…

So I guess that’s a bit confusing?? I’m betting on experimental but thought I’d get feedback before merging across branches…

Remember if you want to try hand tracking you need to checkout the develop or experimental branches at the moment…

M

Late night special…

…added hardware control ofxHardwareDriver to the experimental branch

…motor control
…led control
…accelerometer info

based on ROS kinect_aux.cpp driver and freenect tilt.c code…

neat

M

Hi All,
please can you help me with this: I’m trying to compile the latest code from gameoverhack (the one from https://github.com/gameoverhack/ofxOpenNI - I guess this is not the experimental one, right?) on Ubuntu 10.10 /64bit. I think I included all the libraries and includes but it looks like I’m still missing something.

  
  
/home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp: In member function ‘bool ofxOpenNIRecorder::startRecord(std::string)’:  
/home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp:265: error: ‘class xn::Recorder’ has no member named ‘Release’  
/home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp:266: error: ‘class xn::MockIRGenerator’ has no member named ‘Release’  
/home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp:267: error: ‘class xn::MockImageGenerator’ has no member named ‘Release’  
/home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp:268: error: ‘class xn::MockDepthGenerator’ has no member named ‘Release’  
/home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp: In member function ‘bool ofxOpenNIRecorder::stopRecord()’:  
/home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp:376: error: ‘class xn::Recorder’ has no member named ‘Release’  

[quote author=“mKarpis”]Hi All,
please can you help me with this: I’m trying to compile the latest code from gameoverhack (the one from https://github.com/gameoverhack/ofxOpenNI - I guess this is not the experimental one, right?) on Ubuntu 10.10 /64bit. I think I included all the libraries and includes but it looks like I’m still missing something.

  
  
/home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp: In member function ‘bool ofxOpenNIRecorder::startRecord(std::string)’:  
/home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp:265: error: ‘class xn::Recorder’ has no member named ‘Release’  
/home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp:266: error: ‘class xn::MockIRGenerator’ has no member named ‘Release’  
/home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp:267: error: ‘class xn::MockImageGenerator’ has no member named ‘Release’  
/home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp:268: error: ‘class xn::MockDepthGenerator’ has no member named ‘Release’  
/home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp: In member function ‘bool ofxOpenNIRecorder::stopRecord()’:  
/home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp:376: error: ‘class xn::Recorder’ has no member named ‘Release’  

[/quote]

so I managed to compile it - previously I didn’t use the unstable source from OpenNI. Problem I’m facing now is that it keeps crashing when I start hand/pose tracking. Below is a backtrace:

  
Program received signal SIGSEGV, Segmentation fault.  
0x00007fffefa0863f in XnVSkeletonGenerator::GetAllAvailablePoses(char**, unsigned int, unsigned int&) () from /usr/lib/libXnVFeatures.so  
(gdb) backtrace   
#0  0x00007fffefa0863f in XnVSkeletonGenerator::GetAllAvailablePoses(char**, unsigned int, unsigned int&) () from /usr/lib/libXnVFeatures.so  
#1  0x000000000043af40 in xn::PoseDetectionCapability::StartPoseDetection (this=0x7fffffffdb10, strPose=0xcdabcc "Psi", user=1)  
    at ../../../../kinect-experimental/OpenNI/Include/XnCppWrapper.h:3587  
#2  0x0000000000439830 in ofxUserGenerator::startPoseDetection (this=0xcdaba8, nID=1) at /home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxUserGenerator.cpp:94  
#3  0x00000000004395c9 in User_NewUser (rGenerator=..., nID=1, pCookie=0xcdaba8) at /home/miro/dev/ext/of/addons/ofxOpenNI/src/ofxUserGenerator.cpp:17  
#4  0x000000000043b29a in xn::UserGenerator::NewUserCallback (hNode=0x7fffe8501c20, user=1, pCookie=0x7fffe8503490)  
    at ../../../../kinect-experimental/OpenNI/Include/XnCppWrapper.h:3785  

Not sure yet what can be the problem. Is there a xml file with all available poses?

During application start I’m getting following ERROR output:

Retrieving depth generator succeed: OK
Retrieving image generator succeed: OK
Retrieving depth generator succeed: OK
Retrieving image generator succeed: OK
** 5403635 [ERROR] Failed setting [2] to [1]: Device Protocol: Bad Parameter sent!
Register viewport failed: Device Protocol: Bad Parameter sent!**
Set mirroring succeed: OK
Retrieving depth generator succeed: OK
Retrieving image generator succeed: OK

Hi All,

Thank for all the collective effort, u guys are offering the kinect community amazing help.
I am trying to compile the last code from gameoverhack, on win7, VS2010 Express.

I have downloaded the file (from the Master branch) and I have installed 0.62OF

It doesn’t compile and I get errors that it cant find ofxHandGenerator and ofxHardwareDriver.

  
c:\users\doros\desktop\openframeworks\apps\examples\kinectgameoverexample\src\testapp.h(41): error C2146: syntax error : missing ';' before identifier 'recordHandTracker'  
2>c:\users\doros\desktop\openframeworks\apps\examples\kinectgameoverexample\src\testapp.h(41): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int  
2>c:\users\doros\desktop\openframeworks\apps\examples\kinectgameoverexample\src\testapp.h(41): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int  
2>c:\users\doros\desktop\openframeworks\apps\examples\kinectgameoverexample\src\testapp.h(41): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int  
2>c:\users\doros\desktop\openframeworks\apps\examples\kinectgameoverexample\src\testapp.h(46): error C2146: syntax error : missing ';' before identifier 'hardware'  
2>c:\users\doros\desktop\openframeworks\apps\examples\kinectgameoverexample\src\testapp.h(46): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int  
2>c:\users\doros\desktop\openframeworks\apps\examples\kinectgameoverexample\src\testapp.h(46): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int  
2>c1xx : fatal error C1903: unable to recover from previous error(s); stopping compilation  

I tried adding adding both .cpp and .h files into OpenNiSample->ofxOpenNI->src
in the solution, but no luck.

Any ideas? Do I need OF0.07?

Thanks

[quote author=“gameover”]Late night special…

…added hardware control ofxHardwareDriver to the experimental branch

…motor control
…led control
…accelerometer info

based on ROS kinect_aux.cpp driver and freenect tilt.c code…

neat

M[/quote]

Hi gameover!

When did you update openframeworks from git (007). I am getting some nasty errors in your “experimental” branch, openNISample007, related to non-existant directories, such as …libs/glew/libs/ The latter should be libs/glew/lib/ . Another error "Library not found for -ljasper. What’s up with that?

Thanks for helping sort this out.

B

@gameover

first i want to thank you for your efforts, great addon.

now i got some newbie questions:

in my app i stretched the displayed kinect image from the rgb camera to 1280x960. now of course the dot that gets drawn at the hand position and the skeleton is off because the hand tracking defaults to 640x480

how can i set the tracking to 1280x960 so that the overlays are at the right position? i tried to put my resolution in the xml setup file and initialized with it but then the app crashed.

at the moment im doing something like this:

  
  
ofCircle(projectPos.x * 2, projectPos.y * 2, projectPos.z / 50 );  
  

but thats of course not really beautiful :D. is there a way i can initialize the whole thing with a custom resolution?

another question would be how i could access the hand coordinates from within my own application … i didn’t find any getters to do that, did i overlook something or do i have to build those functions myself?

[quote author=“panopticon”]@gameover

how can i set the tracking to 1280x960 so that the overlays are at the right position? i tried to put my resolution in the xml setup file and initialized with it but then the app crashed.

at the moment im doing something like this:

  
  
ofCircle(projectPos.x * 2, projectPos.y * 2, projectPos.z / 50 );  
  

[/quote]

Try this:

  
  
ofCircle(progPos.x * ofGetWidth(), progPos.y * ofGetHeight(), progPos.z * ofGetWidth() );