// One of the core methods of PyOpenNI: // It tries to find the exposed class that best matches the given node. BP::object wrapNode(XnNodeHandle node) { if (node == NULL) { return BP::object(); } XnNodeInfo* info = xnGetNodeInfo(node); const XnProductionNodeDescription* desc = xnNodeInfoGetDescription(info); XnProductionNodeType original = desc->Type; if (isInstanceOf(original, XN_NODE_TYPE_PRODUCTION_NODE)) { if (isInstanceOf(original, XN_NODE_TYPE_GENERATOR)) { if (isInstanceOf(original, XN_NODE_TYPE_MAP_GENERATOR)) { if (isInstanceOf(original, XN_NODE_TYPE_DEPTH)) { return BP::object(xn::DepthGenerator(node)); } if (isInstanceOf(original, XN_NODE_TYPE_IMAGE)) { return BP::object(xn::ImageGenerator(node)); } if (isInstanceOf(original, XN_NODE_TYPE_SCENE)) { return BP::object(xn::SceneAnalyzer(node)); } return BP::object(xn::MapGenerator(node)); } if (isInstanceOf(original, XN_NODE_TYPE_GESTURE)) { return BP::object(xn::GestureGenerator(node)); } if (isInstanceOf(original, XN_NODE_TYPE_USER)) { return BP::object(xn::UserGenerator(node)); } if (isInstanceOf(original, XN_NODE_TYPE_AUDIO)) { return BP::object(xn::AudioGenerator(node)); } return BP::object(xn::Generator(node)); } return BP::object(xn::ProductionNode(node)); } //This should never happen PyErr_SetString(PyExc_TypeError, "Couldn't find appropiate type to wrap node."); throw BP::error_already_set(); }
XnStatus PlayerImpl::EnumerateNodes(XnNodeInfoList** ppList) { XnStatus nRetVal = XN_STATUS_OK; nRetVal = xnNodeInfoListAllocate(ppList); XN_IS_STATUS_OK(nRetVal); for (PlayedNodesHash::Iterator it = m_playedNodes.begin(); it != m_playedNodes.end(); ++it) { XnNodeInfo* pNodeInfo = xnGetNodeInfo(it.Value().hNode); nRetVal = xnNodeInfoListAddNode(*ppList, pNodeInfo); if (nRetVal != XN_STATUS_OK) { xnNodeInfoListFree(*ppList); return (nRetVal); } } return (XN_STATUS_OK); }