#include "stdafx.h"
#include <XnOS.h>
#include <math.h>
#include <XnCppWrapper.h>
using namespace xn;
int _tmain(int argc, _TCHAR* argv[])
{
XnStatus nRetVal = XN_STATUS_OK;
Context context;
nRetVal = context.Init();
if (nRetVal != XN_STATUS_OK)
{
printf("Read failed: %s\n", xnGetStatusString(nRetVal));
return 0;
}
DepthGenerator depth;
nRetVal=depth.Create(context);
XnMapOutputMode mapMode;
mapMode.nXRes = XN_VGA_X_RES;
mapMode.nYRes = XN_VGA_Y_RES;
mapMode.nFPS = 30;
nRetVal= depth.SetMapOutputMode(mapMode);
nRetVal = context.StartGeneratingAll();
XnUInt32 nMiddleIndex = XN_VGA_X_RES*XN_VGA_Y_RES/2+XN_VGA_X_RES/2;
while (TRUE)
{
nRetVal = context.WaitOneUpdateAll(depth);
const XnDepthPixel* pDepthMap = depth.GetDepthMap();
printf("Middle pixel is %u millimeters away\n",pDepthMap[nMiddleIndex]);
}
context.Shutdown();
system("pause");
return 0;
}
#include <XnOS.h>
#include <math.h>
#include <XnCppWrapper.h>
using namespace xn;
int _tmain(int argc, _TCHAR* argv[])
{
XnStatus nRetVal = XN_STATUS_OK;
Context context;
nRetVal = context.Init();
if (nRetVal != XN_STATUS_OK)
{
printf("Read failed: %s\n", xnGetStatusString(nRetVal));
return 0;
}
DepthGenerator depth;
nRetVal=depth.Create(context);
XnMapOutputMode mapMode;
mapMode.nXRes = XN_VGA_X_RES;
mapMode.nYRes = XN_VGA_Y_RES;
mapMode.nFPS = 30;
nRetVal= depth.SetMapOutputMode(mapMode);
nRetVal = context.StartGeneratingAll();
XnUInt32 nMiddleIndex = XN_VGA_X_RES*XN_VGA_Y_RES/2+XN_VGA_X_RES/2;
while (TRUE)
{
nRetVal = context.WaitOneUpdateAll(depth);
const XnDepthPixel* pDepthMap = depth.GetDepthMap();
printf("Middle pixel is %u millimeters away\n",pDepthMap[nMiddleIndex]);
}
context.Shutdown();
system("pause");
return 0;
}