Data structure of nuitrack.UserFrame?


In the sample code of SegmantPaint.cs of this tutorial like the following. What would frame[i] and frame[i, j] mean? I tried to print it out but all of them are zero.

User Segment Visualization

void ColorizeUser(nuitrack.UserFrame frame)

for (int i = 0; i < (cols * rows); i++)
Color32 currentColor = colorsList[frame[i]];

    int ptr = i * 4;
    outSegment[ptr] = currentColor.a;
    outSegment[ptr + 1] = currentColor.r;
    outSegment[ptr + 2] = currentColor.g;
    outSegment[ptr + 3] = currentColor.b;


Hi, Alex.
Each pixel from (cols * rows) belongs to either one of the users’ silhouettes in front of the camera (there are no more than 6), or a background. Thus, frame [i] == 0 is the background, and frame [i] == 1…6 is the user’s silhouette.
Sorry for my bad English.

Hi Aleksey,

Thanks for the prompt reply and your English is perfect.So frame[i] is a variable indicates whether user i is in this pixel or not, right?

Here [i] is not a user index.
i = cols x rows, this is a big number. For example, when the sensor resolution 640х480 would be 307200 pixels. A user maximum of 6. User index is the value in frame[i], but if this value is 0 it means the pixel [i] does not belong to any of the 6 possible users.
Thus, we will find out if each of the above mentioned 307200 pixels belong to any of the users or background.

Thank you, Aleksey.

BTW, I also found frame[i, j] in the class definition. Does it have the same meaning as frame[i]?

Hi, Alex.
I have not worked with frame[i, j], but I think this is the same. Can’t check now.

1 Like