Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenNI UserTracker.java sample crashes

I've built OpenNI and Sensor from source on Github and installed Nite. I've tested this on Debian with 2.6.39 kernel and with different versions of Java, and on another computer with Lubuntu 11.04 and also with OpenNI unstable and avin2 Sensor - same result. I've also tested with prebuilt binaries.

The UserTracker sample in C++ and .NET works, but the UserTracker.java runs, detects my silhouette, and then the JVM crashes when I make the calibration pose. This is the output before the crash:

New user 1
Pose Psi detected for 1

I've tried playing around with the code, but I can't find the piece of code that causes it - it doesn't crash in PoseDetectedObserver.update.

Here is the link to the example in question: https://github.com/OpenNI/OpenNI/blob/master/Samples/UserTracker.java/org/OpenNI/Samples/UserTracker/UserTracker.java

Has anyone else encountered this problem, or perhaps sees what could be wrong?

edit: I've turned on logging in the SamplesConfig.xml, and the Java samples output these warnings on startup, while the C++ and .NET samples, just have that last one - that's the only difference I find in the logs.

  125 INFO       OpenNI version is 1.3.2 (Build 3)-Linux-x86 (Jul 28 2011 03:43:14)
  141 INFO       Filter Info - minimum severity: WARNING, masks: ALL
 2482 WARNING    Failed loading lib: /usr/lib/libXnVFeatures_1_3_0.so: undefined symbol: xnOSStrFormat

 2489 WARNING    Failed to load '/usr/lib/libXnVFeatures_1_3_0.so' - missing dependencies?
 4080 WARNING    Failed loading lib: /usr/lib/libXnVHandGenerator_1_3_0.so: undefined symbol: xnOSStrFormat

 4087 WARNING    Failed to load '/usr/lib/libXnVHandGenerator_1_3_0.so' - missing dependencies?
 7581 WARNING    Open named event: failed to open key file (2) - event might not exist...

edit2: I've now set a bounty and here's a verbose log file and dump from the latest unstable versions of OpenNI, NITE and avin2's SensorKinect on Lubuntu 11.04: http://pastebin.com/anG18agp http://pastebin.com/mAkf0G6M

like image 581
HairyFotr Avatar asked Jul 26 '11 14:07

HairyFotr


1 Answers

there is an error in the java wrapper classes of OpenNI:

In org_OpenNI_NativeMethods.cpp is reads:

void XN_CALLBACK_TYPE PoseDetectionHandler(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
{
    CallbackCookie* pCallback = (CallbackCookie*)pCookie;
    JNIEnvSupplier supplier;
    jstring jPose = supplier.GetEnv()->NewStringUTF(strPose);
    supplier.GetEnv()->CallVoidMethod(pCallback->obj, pCallback->mid, jPose, user);
    supplier.GetEnv()->ReleaseStringUTFChars(jPose, strPose);
}

But you are not supposed to releaseStringUTF a string allocated with newStringUTF... therefore it crashes.. See here for an example: http://www.velocityreviews.com/forums/t144581-crash-while-calling-releasestringutfchars-for-newstringutf-string.html

Get the source code... Uncomment the release line.. build the OpenNI.jni.dll and the usetracker.java will run!

Best regards, David

like image 66
David Avatar answered Sep 27 '22 17:09

David