Hi,
Im trying to make this code work but only thing that I get is depth. Im trying to find world positions.
Right know worldPoint.X, worldPoint.Y are always 0.
void PrintDepth(DepthFrame depthFrame,
CoordinateMapper mapper)
{
if (depthFrame != null)
{
int width = depthFrame.Width;
int height = depthFrame.Height;
long frameIndex = depthFrame.FrameIndex;
//determine if buffer needs to be reallocated
if (width != _lastWidth || height != _lastHeight)
{
_buffer = new short[width * height];
_lastWidth = width;
_lastHeight = height;
}
depthFrame.CopyData(ref _buffer);
int index = (int)((width * (height / 2.0f)) + (width / 2.0f));
short middleDepth = _buffer[index];
Vector3D worldPoint = mapper.MapDepthPointToWorldSpace(new Vector3D(width / 2.0f, height / 2.0f, middleDepth));
Vector3D depthPoint = mapper.MapWorldPointToDepthSpace(worldPoint);
Debug.Log("depth frameIndex: " + frameIndex
+ " width: " + width
+ " height: " + height
+ " middleDepth: " + middleDepth
+ " wX: " + worldPoint.X
+ " wY: " + worldPoint.Y
+ " wZ: " + worldPoint.Z
+ " dX: " + depthPoint.X
+ " dY: " + depthPoint.Y
+ " dZ: " + depthPoint.Z + " frameCount: " + _frameCount);
}
}