0
$\begingroup$

Rosanswers logo

Hi everyone,

I've been trying to use the SaveCalibrationDataToFile function in OpenNI but so far, it hasn't been going so well. When I try to call it, it returns a

Save calibration to file failed: This operation is invalid!

Here's the few lines of code:

  if (g_UserGenerator.GetSkeletonCap().IsCalibrated(nId)){
      XnStatus nRetVal = g_UserGenerator.GetSkeletonCap().SaveCalibrationDataToFile(nId, calib.bin);
      if (nRetVal != XN_STATUS_OK)
          printf("Save calibration to file failed: %s\n", xnGetStatusString(nRetVal));
  }

I also downloaded someone else's calibration file and tried to load it, but it yielded the same "operation is invalid" message. Anyone have any clues?

Thanks

Update: I tried installing ROS and OpenNI via source in order to use the newest version, but it still displays the horrid and vague "invalid" message.

Update2: I installed the latest unstable version of OpenNI and SaveCalibrationDataToFile works! For anyone who wants to do that, http://groups.google.com/group/openni-dev/msg/6ac27daf08ac31a9 will prove to be very useful


Originally posted by daaango on ROS Answers with karma: 101 on 2011-07-20

Post score: 4


Original comments

Comment by JoeRomano on 2011-08-08:
In main.cpp of NiUserTracker you'll notice several callback functions that occur when a new user is found (line 87), or pose detected (line 106). If you insert the call to LoadCalibration into either of these functions it should work. I would recommend replacing line 110 from PoseDetected with this

Comment by qdocehf on 2011-08-08:
Also, is there a way to make it automatically load the data. From looking at the code, it seems as if I need to type in 'L' every time I want it to apply the saved data to users.

Comment by qdocehf on 2011-08-08:
Do you mean "UserCalibration_CalibrationEnd" or "UserCalibration_CalibrationComplete"? "UserCalibration_CalibrationStart" does not have this line.

Comment by JoeRomano on 2011-08-08:
g_UserGenerator.GetSkeletonCap().SaveCalibrationDataToFile(aUserIDs[i], XN_CALIBRATION_FILE_NAME);

Comment by daaango on 2011-08-08:
To get it to save calibration, all you have to do is paste "g_UserGenerator.GetSkeletonCap().IsCalibrated(aUserIDs[i])" into the XN_CALLBACK_TYPE UserCalibration_CalibrationStart function, specifically after "g_UserGenerator.GetSkeletonCap().StartTracking(nId)" which is around line 130.

Comment by qdocehf on 2011-08-08:
From daaango's update, it seems as though this feature is already in the latest unstable version of OpenNI. All I want to know is what commands I need to use to get this to work.

Comment by qdocehf on 2011-08-08:
I installed the latest unstable version, but when I use the Sample-NiUserTracker, it does not automatically save the calibration. Is there a different program that I need to run to use it? Also, do I need to create a file on my own, or does it automatically create one?

Comment by Miguel Prada on 2011-08-06:
It's nice to know this works with newer versions of openni :) you should answer the question yourself so that some admin can mark it as answered.

Comment by daaango on 2011-08-02:
I was hoping it would maybe be a usage error on my part or something, but I guess deep down I had an inclination that it had something to do with openni... Hopefully someone who deals with OpenNI integration in ROS will stumble upon this thread and provide some insight!

Comment by Miguel Prada on 2011-08-01:
I'm having the same issue, and the only thing I can think of is that this might be a OpenNI version issue. The only people I've heard that has been able to make it work used a more recent version of OpenNI. Hopefully when a newer version is released it will be fixed.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Looks like it has to do with the ROS version of OpenNI, as saving to file works when using the unstable version of OpenNI. Refer to the original post for a link to instructions on how to do that.

Special thanks to Miguel Prada and Asomerville!


edit: For those who wish to test this for themselves (specifically qdocehf cough cough), after installing OpenNI navigate to the folder OpenNI/Samples/NiUserTracker/ and copy the following files to a new directory: SceneDrawer.cpp SceneDrawer.h main.cpp

Open up main.cpp and after line 146, paste

g_UserGenerator.GetSkeletonCap().SaveCalibrationDataToFile(nId, "calibration.bin")

and then compile the file with g++:

g++ -o NiUserTracker SceneDrawer.cpp main.cpp -I/usr/include/ni/ -l'OpenNI' -l'glut'

This will simply save the calibration of any user who performs the psi pose (continuously overwriting the .bin file). This is meant to just be a quick demo to make sure saving calibration data to file works. There is already a function on line 167 that is supposed to save calibration when the s key is pushed, but I must be using it wrong because I didn't get it working and don't really care for it enough to figure it out.

edit2: For testing loading calibration files, around line 90 of main.cpp, just paste in the following code:

g_UserGenerator.GetSkeletonCap().LoadCalibrationDataFromFile(nId, "calibration.bin");
g_UserGenerator.GetPoseDetectionCap().StopPoseDetection(nId);
g_UserGenerator.GetSkeletonCap().StartTracking(nId);

This will simply load up a calibration file as soon as a new user detected, so you'll want to fiddle around some more with code to make sure a calibration file is available, make sure its not requesting calibration after loading, etc...


Originally posted by daaango with karma: 101 on 2011-08-08

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by daaango on 2011-08-09:
you're right, sorry about that. I deleted UserCalibration_CalibrationEnd completely from my version as its not called anywhere in the program.

Comment by qdocehf on 2011-08-09:
Thanks. By the way, the main method in main.cpp uses UserCalibration_CalibrationComplete, not UserCalibration_CalibrationEnd. The safest thing to do would probably be to just paste the line into both methods.

Comment by daaango on 2011-08-08:
check the post! I added a second edit

Comment by qdocehf on 2011-08-08:
What about LoadCalibrationFromFile? The only place that I can find where it is called is when you push the 'L' key, but can it be done automatically? P.S. Sorry about asking so many questions.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.