// -------------------------------- // Code // -------------------------------- void initConstants() { // Primary Streams int nIndex = 0; g_PrimaryStream.pValues[nIndex++] = "Any"; g_PrimaryStream.pValues[nIndex++] = xnProductionNodeTypeToString(XN_NODE_TYPE_DEPTH); g_PrimaryStream.pValues[nIndex++] = xnProductionNodeTypeToString(XN_NODE_TYPE_IMAGE); g_PrimaryStream.pValues[nIndex++] = xnProductionNodeTypeToString(XN_NODE_TYPE_IR); g_PrimaryStream.pValues[nIndex++] = xnProductionNodeTypeToString(XN_NODE_TYPE_AUDIO); g_PrimaryStream.nValuesCount = nIndex; // Registration nIndex = 0; g_Registration.pValues[nIndex++] = FALSE; g_Registration.pValueToName[FALSE] = "Off"; g_Registration.pValues[nIndex++] = TRUE; g_Registration.pValueToName[TRUE] = "Depth -> Image"; g_Registration.nValuesCount = nIndex; // Resolutions nIndex = 0; g_Resolution.pValues[nIndex++] = XN_RES_QVGA; g_Resolution.pValueToName[XN_RES_QVGA] = Resolution(XN_RES_QVGA).GetName(); g_Resolution.pValues[nIndex++] = XN_RES_VGA; g_Resolution.pValueToName[XN_RES_VGA] = Resolution(XN_RES_VGA).GetName(); g_Resolution.pValues[nIndex++] = XN_RES_SXGA; g_Resolution.pValueToName[XN_RES_SXGA] = Resolution(XN_RES_SXGA).GetName(); g_Resolution.pValues[nIndex++] = XN_RES_UXGA; g_Resolution.pValueToName[XN_RES_UXGA] = Resolution(XN_RES_UXGA).GetName(); g_Resolution.nValuesCount = nIndex; }
XN_C_API XnStatus xnProductionNodeDescriptionToString(const XnProductionNodeDescription* pDescription, XnChar* csResult, XnUInt32 nSize) { XnStatus nRetVal = XN_STATUS_OK; XN_VALIDATE_INPUT_PTR(pDescription); XN_VALIDATE_INPUT_PTR(csResult); XnUInt32 nWritten = 0; nRetVal = xnOSStrFormat(csResult, nSize, &nWritten, "%s: %s/%s/", xnProductionNodeTypeToString(pDescription->Type), pDescription->strVendor, pDescription->strName); XN_IS_STATUS_OK(nRetVal); nRetVal = xnVersionToString(&pDescription->Version, csResult + nWritten, nSize - nWritten); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
static XnBool xnIsNodeMatch(XnContext* pContext, const XnNodeQuery* pQuery, XnNodeInfo* pNodeInfo) { // check existing node XnNodeHandle hNode = xnNodeInfoGetRefHandle(pNodeInfo); if (pQuery->bExistingNodeOnly && (hNode == NULL)) { return (FALSE); } if (pQuery->bNonExistingNodeOnly && (hNode != NULL)) { return (FALSE); } if (!xnIsInfoQueryMatch(pQuery, pNodeInfo)) { if (hNode != NULL) { xnProductionNodeRelease(hNode); } return (FALSE); } // check if we need to create an instance, to check capabilities if (pQuery->nSupportedCapabilities > 0 || pQuery->nSupportedMapOutputModes > 0 || pQuery->nMinUserPositions > 0) { if (hNode == NULL) { const XnProductionNodeDescription* pDescription = xnNodeInfoGetDescription(pNodeInfo); xnLogVerbose(XN_MASK_OPEN_NI, "Creating node '%s' of type '%s' for querying...", pDescription->strName, xnProductionNodeTypeToString(pDescription->Type)); XnStatus nRetVal = xnCreateProductionTree(pContext, pNodeInfo, &hNode); if (nRetVal != XN_STATUS_OK) { xnLogWarning(XN_MASK_OPEN_NI, "Failed to create node of type '%s' for querying: %s", xnProductionNodeTypeToString(pDescription->Type), xnGetStatusString(nRetVal)); return (FALSE); } } } XnBool bResult = xnIsNodeInstanceMatch(pQuery, hNode); // in any case, we need to release the node. if we created it, this will cause it to be destroyed. If we just took // a reference to it, we need to release it. if (hNode != NULL) { xnProductionNodeRelease(hNode); } return (bResult); }