Esempio n. 1
0
XnStatus xnXmlReadCropping(const TiXmlElement* pOpcode, XnCropping* pCropping)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	nRetVal = xnXmlReadBoolAttribute(pOpcode, "enabled", &pCropping->bEnabled);
	XN_IS_STATUS_OK(nRetVal);
	
	XnInt nValue;
	nRetVal = xnXmlReadIntAttribute(pOpcode, "xOffset", &nValue);
	XN_IS_STATUS_OK(nRetVal);
	pCropping->nXOffset = nValue;

	nRetVal = xnXmlReadIntAttribute(pOpcode, "yOffset", &nValue);
	XN_IS_STATUS_OK(nRetVal);
	pCropping->nYOffset = nValue;

	nRetVal = xnXmlReadIntAttribute(pOpcode, "xSize", &nValue);
	XN_IS_STATUS_OK(nRetVal);
	pCropping->nXSize = nValue;

	nRetVal = xnXmlReadIntAttribute(pOpcode, "ySize", &nValue);
	XN_IS_STATUS_OK(nRetVal);
	pCropping->nYSize = nValue;
	
	return (XN_STATUS_OK);
}
Esempio n. 2
0
XnStatus xnConfigureProperty(XnNodeHandle hNode, const TiXmlElement* pOpcode)
{
	XnStatus nRetVal = XN_STATUS_OK;

	const XnChar* strName;
	nRetVal = xnXmlReadStringAttribute(pOpcode, "name", &strName);
	XN_IS_STATUS_OK(nRetVal);

	const XnChar* strType;
	nRetVal = xnXmlReadStringAttribute(pOpcode, "type", &strType);
	XN_IS_STATUS_OK(nRetVal);

	if (strcmp(strType, "int") == 0)
	{
		XnInt nValue;
		nRetVal = xnXmlReadIntAttribute(pOpcode, "value", &nValue);
		XN_IS_STATUS_OK(nRetVal);

		nRetVal = xnSetIntProperty(hNode, strName, nValue);
		if (nRetVal != XN_STATUS_OK)
		{
			xnLogError(XN_MASK_OPEN_NI, "Failed to set property '%s' from xml: %s", strName, xnGetStatusString(nRetVal));
			return nRetVal;
		}
	}
	else if (strcmp(strType, "real") == 0)
	{
		XnDouble dValue;
		nRetVal = xnXmlReadRealAttribute(pOpcode, "value", &dValue);
		XN_IS_STATUS_OK(nRetVal);

		nRetVal = xnSetRealProperty(hNode, strName, dValue);
		if (nRetVal != XN_STATUS_OK)
		{
			xnLogError(XN_MASK_OPEN_NI, "Failed to set property '%s' from xml: %s", strName, xnGetStatusString(nRetVal));
			return nRetVal;
		}
	}
	else if (strcmp(strType, "string") == 0)
	{
		const XnChar* strValue;
		nRetVal = xnXmlReadStringAttribute(pOpcode, "value", &strValue);
		XN_IS_STATUS_OK(nRetVal);

		nRetVal = xnSetStringProperty(hNode, strName, strValue);
		if (nRetVal != XN_STATUS_OK)
		{
			xnLogError(XN_MASK_OPEN_NI, "Failed to set property '%s' from xml: %s", strName, xnGetStatusString(nRetVal));
			return nRetVal;
		}
	}
	else
	{
		XN_LOG_ERROR_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_OPEN_NI, "Invalid property type: %s", strType);
	}

	return (XN_STATUS_OK);
}
Esempio n. 3
0
XnStatus xnXmlReadWaveOutputMode(const TiXmlElement* pOpcode, XnWaveOutputMode* pWaveOutputMode)
{
	XnStatus nRetVal = XN_STATUS_OK;

	XnInt nValue;
	nRetVal = xnXmlReadIntAttribute(pOpcode, "sampleRate", &nValue);
	XN_IS_STATUS_OK(nRetVal);
	pWaveOutputMode->nSampleRate = nValue;

	nRetVal = xnXmlReadIntAttribute(pOpcode, "bitsPerSample", &nValue);
	XN_IS_STATUS_OK(nRetVal);
	pWaveOutputMode->nBitsPerSample = nValue;

	nRetVal = xnXmlReadIntAttribute(pOpcode, "channels", &nValue);
	XN_IS_STATUS_OK(nRetVal);
	pWaveOutputMode->nChannels = nValue;

	return (XN_STATUS_OK);
}
Esempio n. 4
0
//---------------------------------------------------------------------------
// Code
//---------------------------------------------------------------------------
XnStatus xnXmlReadMapOutputMode(const TiXmlElement* pOpcode, XnMapOutputMode* pMapOutputMode)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	XnInt nValue;
	nRetVal = xnXmlReadIntAttribute(pOpcode, "xRes", &nValue);
	XN_IS_STATUS_OK(nRetVal);
	pMapOutputMode->nXRes = nValue;

	nRetVal = xnXmlReadIntAttribute(pOpcode, "yRes", &nValue);
	XN_IS_STATUS_OK(nRetVal);
	pMapOutputMode->nYRes = nValue;

	nRetVal = xnXmlReadIntAttribute(pOpcode, "FPS", &nValue);
	XN_IS_STATUS_OK(nRetVal);
	pMapOutputMode->nFPS = nValue;
	
	return (XN_STATUS_OK);
}
Esempio n. 5
0
XnStatus xnXmlReadUserPosition(const TiXmlElement* pOpcode, XnInt* pnIndex, XnBoundingBox3D* pUserPosition)
{
	XnStatus nRetVal = XN_STATUS_OK;

	nRetVal = xnXmlReadIntAttribute(pOpcode, "index", pnIndex);
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = xnXmlReadBoundingBox3D(pOpcode, pUserPosition);
	XN_IS_STATUS_OK(nRetVal);

	return (XN_STATUS_OK);
}
Esempio n. 6
0
XN_C_API XnStatus xnLogInitFromXmlFile(const XnChar* strFileName)
{
	XnStatus nRetVal = XN_STATUS_OK;

	nRetVal = xnLogInitSystem();
	XN_IS_STATUS_OK(nRetVal);

	TiXmlDocument doc;
	nRetVal = xnXmlLoadDocument(doc, strFileName);
	XN_IS_STATUS_OK(nRetVal);

	TiXmlElement* pRootElem = doc.RootElement();
	if (pRootElem != NULL)
	{
		TiXmlElement* pLog = pRootElem->FirstChildElement("Log");
		if (pLog != NULL)
		{
			XnBool bOn;

			// configure filters
			TiXmlElement* pLogLevel = pLog->FirstChildElement("LogLevel");
			if (pLogLevel != NULL)
			{
				XnInt nValue;
				nRetVal = xnXmlReadIntAttribute(pLogLevel, "value", &nValue);
				XN_IS_STATUS_OK(nRetVal);

				nRetVal = xnLogSetSeverityFilter((XnLogSeverity)nValue);
				XN_IS_STATUS_OK(nRetVal);
			}

			TiXmlElement* pMasks = pLog->FirstChildElement("Masks");
			if (pMasks != NULL)
			{
				TiXmlElement* pMask = pMasks->FirstChildElement("Mask");
				while (pMask != NULL)
				{
					const XnChar* strName;
					nRetVal = xnXmlReadStringAttribute(pMask, "name", &strName);
					XN_IS_STATUS_OK(nRetVal);

					nRetVal = xnXmlReadBoolAttribute(pMask, "on", &bOn);
					XN_IS_STATUS_OK(nRetVal);

					nRetVal = xnLogSetMaskState(strName, bOn);
					XN_IS_STATUS_OK(nRetVal);

					pMask = pMask->NextSiblingElement("Mask");
				}
			}

			// configure writers
			if (pLog->Attribute("writeToConsole"))
			{
				nRetVal = xnXmlReadBoolAttribute(pLog, "writeToConsole", &bOn);
				XN_IS_STATUS_OK(nRetVal);

				nRetVal = xnLogSetConsoleOutput(bOn);
				XN_IS_STATUS_OK(nRetVal);
			}

			if (pLog->Attribute("writeToFile"))
			{
				nRetVal = xnXmlReadBoolAttribute(pLog, "writeToFile", &bOn);
				XN_IS_STATUS_OK(nRetVal);

				nRetVal = xnLogSetFileOutput(bOn);
				XN_IS_STATUS_OK(nRetVal);
			}

			if (pLog->Attribute("writeLineInfo"))
			{
				nRetVal = xnXmlReadBoolAttribute(pLog, "writeLineInfo", &bOn);
				XN_IS_STATUS_OK(nRetVal);

				nRetVal = xnLogSetLineInfo(bOn);
				XN_IS_STATUS_OK(nRetVal);
			}

			// Dumps
			TiXmlElement* pDumps = pLog->FirstChildElement("Dumps");
			if (pDumps != NULL)
			{
				TiXmlElement* pDump = pDumps->FirstChildElement("Dump");
				while (pDump != NULL)
				{
					const XnChar* strName;
					nRetVal = xnXmlReadStringAttribute(pDump, "name", &strName);
					XN_IS_STATUS_OK(nRetVal);

					nRetVal = xnXmlReadBoolAttribute(pDump, "on", &bOn);
					XN_IS_STATUS_OK(nRetVal);

					nRetVal = xnDumpSetMaskState(strName, bOn);
					XN_IS_STATUS_OK(nRetVal);

					pDump = pDump->NextSiblingElement("Dump");
				}
			}
		}
	}

	return (XN_STATUS_OK);
}