XnStatus XnExportedSensorGenerator::EnumerateProductionTrees(xn::Context& context, xn::NodeInfoList& TreesList, xn::EnumerationErrors* pErrors) { XnStatus nRetVal = XN_STATUS_OK; XnProductionNodeDescription Description; GetDescription(&Description); // perform a query to be sure the device we'll find is the same one exported from this DLL. xn::Query query; query.SetVendor(XN_VENDOR_PRIMESENSE); query.SetName(XN_DEVICE_NAME); query.SetMinVersion(Description.Version); query.SetMaxVersion(Description.Version); nRetVal = context.AutoEnumerateOverSingleInput(TreesList, Description, NULL, XN_NODE_TYPE_DEVICE, pErrors, &query); XN_IS_STATUS_OK(nRetVal); if (!m_bIsAvailableInLowBand) { xn::NodeInfoList::Iterator it = TreesList.Begin(); while (it != TreesList.End()) { xn::NodeInfoList::Iterator curr = it; it++; xn::NodeInfo node = *curr; // take sensor node xn::NodeInfo sensorNode = *node.GetNeededNodes().Begin(); XnBool bIsLowBand; nRetVal = XnSensorIO::IsSensorLowBandwidth(sensorNode.GetCreationInfo(), &bIsLowBand); XN_IS_STATUS_OK(nRetVal); if (bIsLowBand) { // sensor is low band nRetVal = TreesList.Remove(curr); XN_IS_STATUS_OK(nRetVal); } } if (TreesList.IsEmpty()) { return XN_STATUS_NO_NODE_PRESENT; } } return (XN_STATUS_OK); }
XnStatus XnExportedSensorImageGenerator::EnumerateProductionTrees(xn::Context& context, xn::NodeInfoList& TreesList, xn::EnumerationErrors* pErrors) { XnStatus nRetVal = XN_STATUS_OK; nRetVal = XnExportedSensorGenerator::EnumerateProductionTrees(context, TreesList, pErrors); XN_IS_STATUS_OK(nRetVal); XnStringToBoolHash Devices; // make sure device has image CMOS xn::NodeInfoList::Iterator it = TreesList.Begin(); while (it != TreesList.End()) { xn::NodeInfoList::Iterator curr = it; it++; xn::NodeInfo node = *curr; // take sensor node xn::NodeInfo sensorNode = *node.GetNeededNodes().Begin(); XnBool bHasImageCMOS = TRUE; if (XN_STATUS_OK != Devices.Get(sensorNode.GetCreationInfo(), bHasImageCMOS)) { // wasn't checked yet. check it now xn::Device sensor; nRetVal = sensorNode.GetInstance(sensor); XN_IS_STATUS_OK(nRetVal); XnBool bShouldCreated = (!sensor.IsValid()); if (bShouldCreated) { nRetVal = context.CreateProductionTree(sensorNode); XN_IS_STATUS_OK(nRetVal); nRetVal = sensorNode.GetInstance(sensor); XN_IS_STATUS_OK(nRetVal); } // This is an ugly patch to find out if this sensor has an image CMOS. It will be fixed // in future firmwares so we can just ask. XnCmosBlankingUnits units; units.nCmosID = XN_CMOS_TYPE_IMAGE; nRetVal = sensor.GetGeneralProperty(XN_MODULE_PROPERTY_CMOS_BLANKING_UNITS, sizeof(units), &units); if (nRetVal != XN_STATUS_OK || units.nUnits == 0) { // Failed. this means no image CMOS bHasImageCMOS = FALSE; } if (bShouldCreated) { sensor.Release(); } // add to checked list Devices.Set(sensorNode.GetCreationInfo(), bHasImageCMOS); } if (!bHasImageCMOS) { // remove it from enumeration nRetVal = TreesList.Remove(curr); XN_IS_STATUS_OK(nRetVal); } } if (TreesList.IsEmpty()) { return XN_STATUS_NO_NODE_PRESENT; } return (XN_STATUS_OK); }