KinectUtil not writing intrinsic data file -my fix

Home Forums AR Sandbox Forum KinectUtil not writing intrinsic data file -my fix

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2784
    robbo
    Participant

    Hi Folks,
    So I saw that with the latest updates that if you do a fresh PullPackage install that the “KinectUtil getCalib 0” step returns a protocol error and doesn’t write the intrinsic calibration parameters data file which looks like this:

    Intrinsic camera parameter file /opt/Vrui-12.2/etc/Kinect-4.1/IntrinsicParameters-A00366A18104044A.dat

    which means that when you go to try and run ‘Rawkinectviewer’ and start calibrating your box that you’ll get errors and won’t be able to continue.

    I’m not very good at coding but I am trying to learn so I took this as an opportunity to learn and see if I could debug it. The TLDR is I updated some code in Camera.cpp source file. If you delete KinectUtil and recompile it with the updated code it should work for you. Here is a pastebin link:
    Camera.cpp updated source code

    #2785
    robbo
    Participant

    I wrote a reply explaining how I got to this solution but the forum won’t let me reply so I put the text in a pastebin link for anyone that’s interested.

    how I came to my solution, explanation.

    #2792
    robbo
    Participant

    Here is a summary the differences between the original Camera.cpp and the new modified one. It should explain a little more succinctly and technically than my previous reply.

    In the original version (../../../src/PullPackage/Camera.cpp), there are two read functions:

    void read(int subsection, IO::File& file)
    void read(IO::File& file)

    In the Kinect-4.1 version (../../../src/PullPackage/Kinect-4.1/Kinect/Camera.cpp), there are three read functions:

    void read(int subsection, IO::File& file, size_t bytesToRead)
    void read(int subsection, IO::File& file)
    void read(IO::File& file)

    The new overload in the Kinect-4.1 version (read(int subsection, IO::File& file, size_t bytesToRead)) allows for more controlled reading of calibration data. It checks the number of bytes read against the bytesToRead parameter, ensuring that it doesn’t read beyond the intended data size. This can prevent buffer overruns and makes the function more robust when dealing with potentially incomplete or corrupted data.

    This change reflects an improvement in error handling and data safety in the newer Kinect-4.1 version of the code.

    #2793
    robbo
    Participant

    I was concerned that the data being passed to the rest of the KinectUtil program to create the Intrinsic parameters file wouldn’t be correct since the handling of that data had changed so I asked it to check and this is what it told me.

    After analyzing both Camera.cpp files, I can confirm the differences in the expected number of bytes to read for the calibration parameters:

    In the original version (../../../src/PullPackage/Camera.cpp):

    calibrationParameterReplySizes[0] = 126
    calibrationParameterReplySizes[1] = 16
    calibrationParameterReplySizes[2] = 12
    calibrationParameterReplySizes[3] = 330 or 342 (depending on the Kinect model)
    In the Kinect-4.1 version (../../../src/PullPackage/Kinect-4.1/Kinect/Camera.cpp):

    The expected sizes are exactly the same as the original version.
    The key difference is not in the expected sizes, but in how the reading is handled:

    The original version reads the entire expected size for each subset without any additional checks.

    The Kinect-4.1 version introduces a new read function that takes a bytesToRead parameter, allowing it to handle cases where the actual received data might be less than expected. It checks the number of bytes read against the bytesToRead parameter, ensuring that it doesn’t read beyond the actual data size.

    This change in the Kinect-4.1 version makes the code more robust when dealing with potentially incomplete or corrupted data, but it doesn’t change the expected number of bytes to read. Both versions expect to read the same amount of data; the Kinect-4.1 version just handles potential discrepancies more gracefully.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.