none
Using ExportVolumeBlock from Kinect Fusion SDK RRS feed

  • Question

  • I'm playing around with the newly released Kinect Fusion SDK. Now I'm pretty new to C++ coming from Objective-C and I'm having difficulties interpreting the 'Documentation' of some of the new functions.

    ExportVolumeBlock is the function I'm trying to use to isolate part of a volume (the face).

    public:
    HRESULT ExportVolumeBlock(
         UINT sourceOriginX,
         UINT sourceOriginY,
         UINT sourceOriginZ,
         UINT destinationResolutionX,
         UINT destinationResolutionY,
         UINT destinationResolutionZ,
         UINT voxelStep,
         UINT cbVolumeBlock,
         SHORT *pVolumeBlock
    )

    Now the ones I'm not quite sure about are cbVolumeBlock and pVolumeBlock. Especially the last one states you need to pre-allocate a SHORT and ExportVolumeBlock expects a SHORT. However the documentation states To access the voxel located at x,y,z use pVolume[z][y][x] But if I pre-allocate a 3D Short like

    SHORT m_pVolumeB[30][30][30];
    m_pVolume->ExportVolumeBlock(0, 0, 0, 30, 30, 30, 1, 8, m_pVolumeB);

    I get the message:

    Error: argument of type "SHORT (*)[30][30]" is incompatible with parameter of type "SHORT *"

    Working with a 1D SHORT I do get some results in it, but I'm not sure if that is the correct way of doing it. Does anyone have more experience with this function?


    • Edited by fsfikke Thursday, May 30, 2013 8:02 AM
    Thursday, May 30, 2013 7:00 AM

Answers

  • You will have to make sure your destination resolution doesn't fall outside the range. The key is cbVolumeBlock is the total bytes not the size of the area.

    	UINT destinationResolutionX = 64;
    	UINT destinationResolutionY = 64;
    	UINT destinationResolutionZ = 64;
    	UINT blocksize = destinationResolutionX * destinationResolutionY * destinationResolutionZ;
    
    	SHORT *pVolumeBlock = new SHORT[blocksize];
    
    	hr = m_pVolume->ExportVolumeBlock( 0, 0, 0, destinationResolutionX, destinationResolutionY, destinationResolutionZ, 1, blockSize * sizeof(SHORT), pVolumeBlock );
    
    	delete [] pVolumeBlock;



    Thursday, May 30, 2013 11:54 PM

All replies

  • You will have to make sure your destination resolution doesn't fall outside the range. The key is cbVolumeBlock is the total bytes not the size of the area.

    	UINT destinationResolutionX = 64;
    	UINT destinationResolutionY = 64;
    	UINT destinationResolutionZ = 64;
    	UINT blocksize = destinationResolutionX * destinationResolutionY * destinationResolutionZ;
    
    	SHORT *pVolumeBlock = new SHORT[blocksize];
    
    	hr = m_pVolume->ExportVolumeBlock( 0, 0, 0, destinationResolutionX, destinationResolutionY, destinationResolutionZ, 1, blockSize * sizeof(SHORT), pVolumeBlock );
    
    	delete [] pVolumeBlock;



    Thursday, May 30, 2013 11:54 PM
  • Thanks that seems to work better. However I'm not 100% sure if it's exactly it. Because the pVolumeBlock only seems to contain values of 0x8000. According to the documentation that means that the voxel is uninitialized. Now I now my m_pVolume contains valid voxels because I'm using it to create a pointcloud that I export and that works fine.
    Saturday, June 1, 2013 6:37 PM