MCPcopy Create free account
hub / github.com/OpenNI/OpenNI / xnConvertProjectiveToRealWorld

Function xnConvertProjectiveToRealWorld

Source/OpenNI/XnOpenNI.cpp:4720–4750  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4718}
4719
4720XN_C_API XnStatus xnConvertProjectiveToRealWorld(XnNodeHandle hInstance, XnUInt32 nCount, const XnPoint3D* aProjective, XnPoint3D* aRealWorld)
4721{
4722 XnStatus nRetVal = XN_STATUS_OK;
4723
4724 XN_VALIDATE_INTERFACE_TYPE(hInstance, XN_NODE_TYPE_DEPTH);
4725
4726 /**
4727 * X_RW = (X_proj / X_res - 1/2) * Z * x_to_z
4728 */
4729
4730 XnMapOutputMode outputMode;
4731 nRetVal = xnGetMapOutputMode(hInstance, &outputMode);
4732 XN_IS_STATUS_OK(nRetVal);
4733
4734 xn::DepthPrivateData* pDepthPrivate = (xn::DepthPrivateData*)hInstance->pPrivateData;
4735 XnDouble fXToZ = pDepthPrivate->GetRealWorldXtoZ();
4736 XnDouble fYToZ = pDepthPrivate->GetRealWorldYtoZ();
4737
4738 for (XnUInt32 i = 0; i < nCount; ++i)
4739 {
4740 XnDouble fNormalizedX = (aProjective[i].X / outputMode.nXRes - 0.5);
4741 aRealWorld[i].X = (XnFloat)(fNormalizedX * aProjective[i].Z * fXToZ);
4742
4743 XnDouble fNormalizedY = (0.5 - aProjective[i].Y / outputMode.nYRes);
4744 aRealWorld[i].Y = (XnFloat)(fNormalizedY * aProjective[i].Z * fYToZ);
4745
4746 aRealWorld[i].Z = aProjective[i].Z;
4747 }
4748
4749 return (XN_STATUS_OK);
4750}
4751
4752XN_C_API XnStatus xnConvertRealWorldToProjective(XnNodeHandle hInstance, XnUInt32 nCount, const XnPoint3D* aRealWorld, XnPoint3D* aProjective)
4753{

Calls 3

xnGetMapOutputModeFunction · 0.85
GetRealWorldXtoZMethod · 0.80
GetRealWorldYtoZMethod · 0.80

Tested by

no test coverage detected