How to get data using cols and rows as parameters in DepthFrame? (Unity3D)

I found byte[] Data, but it is One-dimensional array.

I want to turn this data into a 2D array.

I need help.

Hello. I think this tutorial can help
Short sample:

        nuitrack.DepthFrame depthFrame = NuitrackManager.DepthFrame;
        print(depthFrame[300, 350]); //you can get depth from any point of frame (1D and 2D)

        ushort[,] depth = new ushort[depthFrame.Rows, depthFrame.Cols];
        for (int i = 0; i < depthFrame.Rows; i++)
            for (int j = 0; j < depthFrame.Cols; j++)
                depth[i, j] = depthFrame[i, j];

I used this Code, but I have 2nd problem.

depthFrame.Cols return 640, depthFrame.Rows return 480.
but depthFrame[480, 0] has error : ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.


what is a problem?

This was my mistake.
I was typing rows and columns in reverse. Thank you!

1 Like