Search code examples
c#kinectmeshkinect-sdkkinect-v2

Kinectv2 - How to remove depth color from kinect fusion explorer - wpf example c#?


I have a project with Kinect v2. I have downloaded kinect fusion explorer - wpf example from kinect sdk. In the example, I get a mesh like the left one in the picture. I want to get it like the right one, without colors. Does anybody have an advice to give me that can help me to figure out how to do it? I just want to remove depth colors from the stream.

https://i.sstatic.net/Kyso0.jpg


Solution

  • In this sample, colourization of the voxels is done by multiplying a vector containing each voxel's X, Y, Z coordinate by matrix worldToBGRTransform.

    The default matrix maps X to blue, Y to green and depth to R with some shifts on X and Y (I don't really understand that part).

    To make the output grey you have to map the colours such that R G and B are set equally.

    E.g. you could edit the setup of worldToBGRTransform as follows (MainWindows.xaml.cs line 2893):

    this.worldToBGRTransform = Matrix4.Identity;
    this.worldToBGRTransform.M11 = 0.5f * this.voxelsPerMeter / this.voxelsX;
    this.worldToBGRTransform.M12 = 0.5f * this.voxelsPerMeter / this.voxelsX;
    this.worldToBGRTransform.M13 = 0.5f * this.voxelsPerMeter / this.voxelsX;
    this.worldToBGRTransform.M21 = 0.5f * this.voxelsPerMeter / this.voxelsY;
    this.worldToBGRTransform.M22 = 0.5f * this.voxelsPerMeter / this.voxelsY;
    this.worldToBGRTransform.M23 = 0.5f * this.voxelsPerMeter / this.voxelsY;
    this.worldToBGRTransform.M31 = this.voxelsPerMeter / this.voxelsZ;
    this.worldToBGRTransform.M32 = this.voxelsPerMeter / this.voxelsZ;
    this.worldToBGRTransform.M33 = this.voxelsPerMeter / this.voxelsZ;