0

This fragment of code was taken from OpenNI sample called NiUserTracker

//... some codes...

#define XN_CALIBRATION_FILE_NAME "UserCalibration.bin"

// Save calibration to file
void SaveCalibration()
{
    XnUserID aUserIDs[20] = {0};
    XnUInt16 nUsers = 20;
    g_UserGenerator.GetUsers(aUserIDs, nUsers);
    for (int i = 0; i < nUsers; ++i)
    {
        // Find a user who is already calibrated
        if (g_UserGenerator.GetSkeletonCap().IsCalibrated(aUserIDs[i]))
        {
            // Save user's calibration to file
            g_UserGenerator.GetSkeletonCap().SaveCalibrationDataToFile(aUserIDs[i], XN_CALIBRATION_FILE_NAME);
            break;
        }
    }
}

//... some codes ...
//... some codes ...

 void glutKeyboard (unsigned char key, int x, int y)
{
    switch (key)
    {
        case 27:
            CleanupExit();

        //... some codes...

        case 'S':
            SaveCalibration();
            break;
        case 'L':
            LoadCalibration();
            break;
        }
    }

When I press Shift+s or S (with caps lock on), it does not generate the "UserCalibration.bin." I searched my hard drive entirely, and no such file was found. Afterwards, I disable the "read-only" property from OpenNI folder. The console, when I execute NiUserTracker.exe, does not report any error.

I am most happy with its on-line calibration, which takes a moment to calibrate, I thought this process can be made quicker by loading a user-calibrated file.

Could some point me in the right direction, why I am unable to generate this "UserCalibration.bin" file? I am using Win7 64 bit with 64 bit OpenNI, and Visual Studio 2010 Ultimate (provided by our University for research purpose).

Greatly appreciated.

Regards, ikel

ikel
  • 518
  • 2
  • 6
  • 27

1 Answers1

1

I just did a quick test with two different configurations:

  1. osx 10.6.8 with OpenNI dev 64bit (OpenNI1.5.2.7,Nite1.5.2.7,avin2 SensorKinect5.0.5.2 )
  2. WinXP SP3 with OpenNI dev 32bit (OpenNI1.5.4.0,Nite1.5.2.21,avin2 SensorKinect5.1.2.1)

It doesn't look like a permission's issue. I've modified the SaveCalibration function a bit:

// Save calibration to file
void SaveCalibration()
{
    XnUserID aUserIDs[20] = {0};
    XnUInt16 nUsers = 20;
    g_UserGenerator.GetUsers(aUserIDs, nUsers);
    for (int i = 0; i < nUsers; ++i)
    {
        // Find a user who is already calibrated
        if (g_UserGenerator.GetSkeletonCap().IsCalibrated(aUserIDs[i]))
        {
            // Save user's calibration to file
                        XnStatus saveStatus = g_UserGenerator.GetSkeletonCap().SaveCalibrationDataToFile(aUserIDs[i], XN_CALIBRATION_FILE_NAME);
                        std::cout << "saveStatus: " << saveStatus << std::endl;
                        if(saveStatus == XN_STATUS_OK) std::cout << "calibration saved to file" << std::endl;
                        if(saveStatus == XN_STATUS_NOT_IMPLEMENTED) std::cout << "not implemented, calibration wasn't saved" << std::endl;
            break;
        }
    }
}

I've got STATUS_OK on osx, but XN_STATUS_NOT_IMPLEMENTED (value 65550) on Windows. I've found an interesting post on the OpenNI group. I'm not 100% sure, but it sounds like SaveCalibrationDataToFile might be deprecated in newer versions. This would sort of make sense since the psi(Ψ) pose is no longer required for calibration.

Try to revert to an older version. The OpenNI configuration I use on osx works (saves calibration file but this version also can track skeleton without requiring the psi(Ψ) pose).

HTH

George Profenza
  • 50,687
  • 19
  • 144
  • 218
  • Thanks for the lead to OpenNI forum. In the mean time, I found something interesting from the PrimeSense NITE documentation, **NITE Algorithm.pdf**. Pg 11. _Since previous versions of NITE did not support automatic calibration, NITE provided the ability to save and load the calibration data. Automatic calibration makes this feature obsolete. However, the load/save calibration is still supported for backwards compatibility. If automatic calibration is active (the default), both save and load will fail._ – ikel Sep 25 '12 at 11:33
  • will award you the tick as your suggestion was suitable in the first instance, roll back driver. Thanks for doing the thorough research. – ikel Sep 25 '12 at 11:48
  • @ikel Glad to help. Also thank you for posting the above quote. – George Profenza Sep 25 '12 at 22:20