none
Possibilities of using voxel values data of NuiFusionReconstruction volume with ExportVolumeBlock RRS feed

  • Question

  • Hello,

    I was just scrawling through this forum. My Question: Is it possible to use the volume created with the Kinect Fusion v2 for own raycasting algorithms?

    As I saw here(link removed), the API isn't intended to grant such a feature.

    But in here(link removed) the MS staff admitted, that the feature are something frequently requested and they might be planning to implement them.

    So, is there a possibility? Or are there other known projects with the Kinect depth sensor for scanning 3D geometry in real time? Best would be, if I really could use the voxel data of the Fusion API to perform my raycast as the code is really performant and stable.

    Best regards,
    Eric

    Edit: I couldn't add the links as the forum said, the body cannot contain any links until my account is not verified. 


    • Edited by Eric S2MD Tuesday, June 30, 2015 2:37 PM
    Tuesday, June 30, 2015 2:36 PM

All replies

  • It's possible to access the volume data by doing an export block function and then doing an import block function to bring it back into the volume.

    I haven't found a way to access the volume data without exporting it into it's own array, making the changes I need made, and then importing it back.  Here is some code that adds a multi colored disc at the bottom of the volume (if the volume is named 'scanningvolume').

    I'm not a programmer though, so don't look at this for proper coding technique, it's just how i did it though.

    private bool addOrientationDisk(int BaseColor, bool addPattern, int PatternColor)
            {
                int vX = (int)this.VoxelsX;
                int vY = (int)this.VoxelsY;
                int vZ = (int)this.VoxelsZ;
                short[] voxelVolumeBlock = new short[vX * vY * vZ];
                int[] colorVolumeBlock = new int[vX * vY * vZ];
                this.volumeScanning.ExportVolumeBlock(0, 0, 0, 
                    vX, vY, vZ, 1, 
                    voxelVolumeBlock, 
                    colorVolumeBlock);
    
                //first get the circle size
                int CircleR = vX;
    
                if (CircleR <= 0) { CircleR = 1; }
                if (CircleR > vZ / 3) { CircleR = vZ / 3; }
                if (CircleR > vX / 3) { CircleR = vX / 3; }
    
                //lets first add the non curved area
    
    
                int pitch = vX; //x width
                int slice = (vY * pitch); //y height
                int index = 0;// (z * slice) * (y * pitch) + x;
                int startX = (vX / 2) - CircleR;
                int endX = (vX/2) + CircleR;
                int startY = vY - 2;
                int endY = vY;
                int startZ = (vZ / 2) - CircleR;
                int endZ = (vZ / 2) + CircleR;
                int pRadius = (int)(Math.Pow(CircleR, 2));
                int xVal = 0; //store so it doesn't need to recalculate over and over;
                int zVal = 0;
                double zRV = 0;
                double xRV = 0;
                for (int x = startX; x <= endX; x++)
                {
                    xRV = x - (endX) + CircleR;
                    xVal = (int)Math.Pow(xRV, 2);
                    for (int z = startZ; z <= endZ; z++)
                    {
                        zRV = z - (endZ) + CircleR;
                        zVal = (int)Math.Pow(zRV, 2);
                        
                        //all index zones need to shift down 1 to line up with 0 coordinate sys
                        index = ((z - 1) * slice) + ((endY - 3) * pitch) + (x - 1);
                        voxelVolumeBlock[index] = -1;
                        if (addPattern)
                        {
                            if (x % 16 != 0 && z % 16 != 0)
                            {
                                colorVolumeBlock[index] = BaseColor;
                            }
                            else{
                                colorVolumeBlock[index] = (255 << 24) | (0 << 16) | ((int)(((zRV * (1.0 / CircleR)) * 127) + 128) << 8) | (int)(((xRV * (1.0 / CircleR)) * 127) + 128);
                            }
                            
                        }
                           else{
                                colorVolumeBlock[index] = BaseColor;
                            }
    
                        index = ((z - 1) * slice) + ((endY - 2) * pitch) + (x - 1); //middle
                        if ((xVal + zVal) < pRadius)
                        {//if the x/z are within the radius, we need to make it a positive voxel
                            voxelVolumeBlock[index] = 1;
                        }
                        else{
                            voxelVolumeBlock[index] = -1;
                        }
    
                        if (addPattern)
                        {
                            if (x % 16 != 0 && z % 16 != 0)
                            {
                                colorVolumeBlock[index] = BaseColor;
                            }
                            else
                            {
                                colorVolumeBlock[index] = PatternColor;
                            }
    
                        }
                        else
                        {
                            colorVolumeBlock[index] = BaseColor;
                        }
                        index = ((z - 1) * slice) + ((endY -1) * pitch) + (x - 1); //bottom
                        voxelVolumeBlock[index] = -1;
                        if (addPattern)
                        {
                            if (x % 16 != 0 && z % 16 != 0)
                            {
                                colorVolumeBlock[index] = BaseColor;
                            }
                            else
                            {
                                colorVolumeBlock[index] = (255 << 24) | (255 << 16) | ((int)(((zRV * (1.0 / CircleR)) * 127) + 128) << 8) | (int)(((xRV * (1.0 / CircleR)) * 127) + 128);
                            }
    
                        }
                        else
                        {
                            colorVolumeBlock[index] = BaseColor;
                        }
    
    
    
                    }
    
                }
    
                this.volumeScanning.ImportVolumeBlock(voxelVolumeBlock, colorVolumeBlock);
                return true;
            }

    Tuesday, June 30, 2015 4:47 PM
  • Hi Jacob,

    Thanks for the quick answer. Do I understand your code right, that in the voxelVolumeBlock a negative value indicates no matter and a positive one indicates matter?

    As I get values in a range of [-32767 32767] (shorts) when I call the ExportVolumeBlock, would it be possible to say, every voxel with a negative value is an "empty" voxel? This would be sufficient for my raycasting attempt.

    Best regards,

    Eric

    Wednesday, July 1, 2015 12:32 PM