void ColorizeUser(nuitrack.UserFrame frame) { userId = CurrentUserTracker.CurrentUser; int pixelid = 0; int pointer = 0; for (int i = 0; i < (frame.Cols * frame.Rows); i += renderStep) { Color32 currentColor = new Color32(0, 0, 0, 0); if (frame[i] == userId) { currentColor = colorsList[frame[i]]; } int ptr = pixelid * 4; outSegment[ptr] = currentColor.a; outSegment[ptr + 1] = currentColor.r; outSegment[ptr + 2] = currentColor.g; outSegment[ptr + 3] = currentColor.b; pixelid++; pointer++; if (pointer == frame.Cols / renderStep) { i += frame.Cols; pointer = 0; } } segmentTexture.LoadRawTextureData(outSegment); segmentTexture.Apply(); segmentSprite = Sprite.Create(segmentTexture, imageRect, UnityEngine.Vector3.one * 0.5f, 100f, 0, SpriteMeshType.FullRect); segmentOut.sprite = segmentSprite; }
void onUpdateUser(nuitrack.UserFrame _userFrame) { numUsers = _userFrame.NumUsers; users = _userFrame.Users; }