PDA

View Full Version : Kinect V2 data buffers not maching for both client and network machines



kirubhaRK
07-02-2015, 06:01 AM
Hi,

The kinect V2 data streams like color and depth coming from network and kinect which is connected to the client machine is different.If i render color buffer from kinect and also color buffer from network machine the data are not matching.For example, i render the kinect color from client machine in the following way,



void kinectcolorframebuffer()
{
// Read color data
IColorFrame* pCFrame = nullptr;
if (pColorFrameReader->AcquireLatestFrame(&pCFrame) == S_OK)
{
pCFrame->CopyConvertedFrameDataToArray( uColorBufferSize, pColorBuffer, ColorImageFormat_Rgba);
pCFrame->Release();
pCFrame = nullptr;
}
}

const CameraSpacePoint& rPt = pCSPoints[colorIndex];

xx =(i-pp_x)*rPt.Z/fl_x;
yy = (j-pp_y)*rPt.Z/fl_y;
zz=rPt.Z;

glColor4ub(pColorBuffer[4 * colorIndex], pColorBuffer[4 * colorIndex + 1], pColorBuffer[4 * colorIndex + 2], pColorBuffer[4 * colorIndex + 3]);

glVertex3f(xx, -yy, rPt.Z);

where as the kinect color from network machine in this way.


void AcquireAndProcessColorFrame()
{
kv2s::IColorFramePtr colorFrame;
if (colorStreamer->AcquireLatestFrame(&colorFrame))
{
UINT bufferSize;
unsigned char* buffer;
colorFrame->AccessRawUnderlyingBuffer(&bufferSize, &buffer);
bufferbyte=reinterpret_cast<BYTE*>(buffer);
}
}

const CameraSpacePoint& rPt2 = pCSS2Points[colorIndex];
xx1 =(i-pp_x)*rPt2.Z/fl_x;
yy1 = (j-pp_y)*rPt2.Z/fl_y;
zz1=rPt2.Z;

glColor4ub(bufferbyte[ 3 *colorIndex], bufferbyte[3 * colorIndex + 1], bufferbyte[3 * colorIndex + 2], bufferbyte[3 * colorIndex + 3]); glVertex3f(xx1, -yy1, zz1);



Here from the above code i have a doubt,

In client machine code, i have displayed color rgb using following code, where i have multiplied the colorindex by 4.

glColor4ub(pColorBuffer[4 * colorIndex], pColorBuffer[4 * colorIndex + 1], pColorBuffer[4 * colorIndex + 2], pColorBuffer[4 * colorIndex + 3]);

In network machine code, i have displayed color rgb using following code, where i have multiplied the colorindex by 3.

glColor4ub(bufferbyte[ 3 *colorIndex], bufferbyte[3 * colorIndex + 1], bufferbyte[3 * colorIndex + 2], bufferbyte[3 * colorIndex + 3]);


if i multiply the colorindex by 4 in network machine code , i get the access violation error, because data not exist for that index.

My questions are,

1. Why data buffers not matching for both client and network machines.

2. How to match data buffers coming from both buffers without any data loss.So that i will get the same data buffer like client machine in network machine also.
Thanks
kirubha