void XnSensorIRGenerator::OnResChanged() { // we calculate the size because the IR stream actually gives out a bigger buffer, but // we want the buffer we return to be with the right size. XnMapOutputMode outputMode; GetMapOutputMode(outputMode); XnUInt32 nPixels = outputMode.nXRes * outputMode.nYRes; XnCropping cropping; GetCropping(cropping); if (cropping.bEnabled) { nPixels = cropping.nXSize * cropping.nYSize; } m_nBufferSize = nPixels * sizeof(XnIRPixel); }
XnStatus XnSensorDepthGenerator::GetUserPosition(XnUInt32 nIndex, XnBoundingBox3D& Position) { XnStatus nRetVal = XN_STATUS_OK; // get XnDepthAGCBin bin; bin.nBin = nIndex; nRetVal = m_pSensor->GetProperty(m_strModule, XN_STREAM_PROPERTY_AGC_BIN, XN_PACK_GENERAL_BUFFER(bin)); XN_IS_STATUS_OK(nRetVal); XnMapOutputMode MapOutputMode; nRetVal = GetMapOutputMode(MapOutputMode); XN_IS_STATUS_OK(nRetVal); // we only support Z position for now Position.LeftBottomNear.Z = bin.nMin; Position.RightTopFar.Z = bin.nMax; Position.LeftBottomNear.X = 0; Position.RightTopFar.X = MapOutputMode.nXRes - 1; Position.LeftBottomNear.Y = 0; Position.RightTopFar.Y = MapOutputMode.nYRes - 1; return (XN_STATUS_OK); }
XnUInt32 XnSensorImageGenerator::FindSupportedInputFormat(XnUInt32* anAllowedInputFormats, XnUInt32 nAllowedInputFormats) { // first check if current one is allowed XnUInt64 nCurrentInputFormat; GetIntProperty(XN_STREAM_PROPERTY_INPUT_FORMAT, nCurrentInputFormat); for (XnUInt32 i = 0; i < nAllowedInputFormats; ++i) { if (anAllowedInputFormats[i] == nCurrentInputFormat) { return (XnUInt32)nCurrentInputFormat; } } // current one is not allowed. find a matching mode and take its input format XnMapOutputMode outputMode; GetMapOutputMode(outputMode); // the order in the allowed input formats is the preferred one for (XnUInt32 iInput = 0; iInput < nAllowedInputFormats; ++iInput) { // see if such a mode exists for (XnUInt32 iMode = 0; iMode < m_nSupportedModesCount; ++iMode) { if (m_aSupportedModes[iMode].nInputFormat == anAllowedInputFormats[iInput] && m_aSupportedModes[iMode].OutputMode.nXRes == outputMode.nXRes && m_aSupportedModes[iMode].OutputMode.nYRes == outputMode.nYRes && m_aSupportedModes[iMode].OutputMode.nFPS == outputMode.nFPS) { return anAllowedInputFormats[iInput]; } } } return INVALID_INPUT_FORMAT; }