本文整理汇总了C++中XnDeviceModuleHolder::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ XnDeviceModuleHolder::Init方法的具体用法?C++ XnDeviceModuleHolder::Init怎么用?C++ XnDeviceModuleHolder::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XnDeviceModuleHolder
的用法示例。
在下文中一共展示了XnDeviceModuleHolder::Init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetInitialState
XnStatus XnStreamReaderDevice::SetInitialState(const XnDeviceConfig* pDeviceConfig, XnPropertySet* pSet)
{
XnStatus nRetVal = XN_STATUS_OK;
// Fix state (remove some properties that we don't wish to reflect in reader device)
XnActualPropertiesHash* pDeviceModule = NULL;
if (XN_STATUS_OK == pSet->pData->Get(XN_MODULE_NAME_DEVICE, pDeviceModule))
{
pDeviceModule->Remove(XN_MODULE_PROPERTY_READ_WRITE_MODE);
pDeviceModule->Remove(XN_MODULE_PROPERTY_PRIMARY_STREAM);
}
// now init base using this state (this will also create module DEVICE)
XnDeviceConfig initConfig;
initConfig.cpConnectionString = pDeviceConfig->cpConnectionString;
initConfig.DeviceMode = pDeviceConfig->DeviceMode;
initConfig.pInitialValues = pSet;
initConfig.SharingMode = pDeviceConfig->SharingMode;
nRetVal = XnStreamDevice::InitImpl(&initConfig);
XN_IS_STATUS_OK(nRetVal);
// now create the rest of the modules and streams (DEVICE was already created)
XnPropertySetData* pPropSetData = pSet->pData;
for (XnPropertySetData::ConstIterator it = pPropSetData->begin(); it != pPropSetData->end(); ++it)
{
// ignore module DEVICE
if (strcmp(XN_MODULE_NAME_DEVICE, it.Key()) == 0)
{
continue;
}
// check if this is a stream
XnActualPropertiesHash::ConstIterator itProp = it.Value()->end();
if (XN_STATUS_OK == it.Value()->Find(XN_STREAM_PROPERTY_TYPE, itProp))
{
XnActualStringProperty* pTypeProp = (XnActualStringProperty*)itProp.Value();
nRetVal = HandleNewStream(pTypeProp->GetValue(), it.Key(), it.Value());
XN_IS_STATUS_OK(nRetVal);
}
else
{
// this is module. create it
XnDeviceModuleHolder* pHolder = NULL;
nRetVal = CreateModule(it.Key(), &pHolder);
XN_IS_STATUS_OK(nRetVal);
// set its props
nRetVal = pHolder->Init(it.Value());
if (nRetVal != XN_STATUS_OK)
{
DestroyModule(pHolder);
return (nRetVal);
}
// and add it
nRetVal = AddModule(pHolder);
if (nRetVal != XN_STATUS_OK)
{
DestroyModule(pHolder);
return (nRetVal);
}
}
} // modules loop
return (XN_STATUS_OK);
}
示例2: CreateStreamImpl
XnStatus XnDeviceBase::CreateStreamImpl(const XnChar* strType, const XnChar* strName, const XnActualPropertiesHash* pInitialSet)
{
XnStatus nRetVal = XN_STATUS_OK;
xnLogInfo(XN_MASK_DDK, "Creating stream '%s' of type '%s'...", strName, strType);
XnDeviceModule* pModule;
if (FindModule(strName, &pModule) == XN_STATUS_OK)
{
// already exists. check sharing mode (when shared, we allow "creating" the same stream)
if (GetSharingMode() != XN_DEVICE_SHARED ||
!IsStream(pModule) ||
strcmp(strType, ((XnDeviceStream*)pModule)->GetType()) != 0)
{
XN_LOG_WARNING_RETURN(XN_STATUS_STREAM_ALREADY_EXISTS, XN_MASK_DDK, "A stream with this name already exists!");
}
// OK, we'll allow this. Just set new configuration
if (pInitialSet != NULL)
{
nRetVal = pModule->BatchConfig(*pInitialSet);
XN_IS_STATUS_OK(nRetVal);
}
}
else
{
// create stream
XnDeviceModuleHolder* pNewStreamHolder = NULL;
nRetVal = CreateStreamModule(strType, strName, &pNewStreamHolder);
XN_IS_STATUS_OK(nRetVal);
XnDeviceStream* pNewStream = (XnDeviceStream*)(pNewStreamHolder->GetModule());
if (pNewStream == NULL)
{
DestroyStreamModule(pNewStreamHolder);
XN_LOG_ERROR_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Internal Error: Invalid new stream!");
}
// initialize the stream
xnLogVerbose(XN_MASK_DDK, "Initializing stream '%s'...", strName);
nRetVal = pNewStreamHolder->Init(pInitialSet);
if (nRetVal != XN_STATUS_OK)
{
DestroyStreamModule(pNewStreamHolder);
return (nRetVal);
}
// set it's mirror value (if not requested otherwise)
XnBool bSetMirror = TRUE;
if (pInitialSet != NULL)
{
XnActualPropertiesHash::ConstIterator it = pInitialSet->end();
if (XN_STATUS_OK == pInitialSet->Find(XN_MODULE_PROPERTY_MIRROR, it))
{
bSetMirror = FALSE;
}
}
if (bSetMirror)
{
nRetVal = pNewStream->SetMirror((XnBool)m_DeviceMirror.GetValue());
if (nRetVal != XN_STATUS_OK)
{
DestroyStreamModule(pNewStreamHolder);
return (nRetVal);
}
}
// add it to the list of existing modules
nRetVal = AddModule(pNewStreamHolder);
if (nRetVal != XN_STATUS_OK)
{
DestroyStreamModule(pNewStreamHolder);
return (nRetVal);
}
xnLogInfo(XN_MASK_DDK, "Stream '%s' was initialized.", strName);
nRetVal = StreamAdded(pNewStream);
XN_IS_STATUS_OK(nRetVal);
xnLogInfo(XN_MASK_DDK, "'%s' stream was created.", strName);
}
return (XN_STATUS_OK);
}