本文整理汇总了C++中NodeInfoList类的典型用法代码示例。如果您正苦于以下问题:C++ NodeInfoList类的具体用法?C++ NodeInfoList怎么用?C++ NodeInfoList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeInfoList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ofToDataPath
//----------------------------------------
bool ofxOpenNICapture::setup(ofxOpenNI & _context, string filename, XnCodecID depthFormat, XnCodecID imageFormat, XnCodecID irFormat, XnCodecID audioFormat){
context = &_context;
csFileName = ofToDataPath(filename);
nodes[CAPTURE_DEPTH_NODE].captureFormat = depthFormat;
nodes[CAPTURE_IMAGE_NODE].captureFormat = imageFormat;
nodes[CAPTURE_IR_NODE].captureFormat = irFormat;
nodes[CAPTURE_AUDIO_NODE].captureFormat = audioFormat;
XnStatus nRetVal = XN_STATUS_OK;
NodeInfoList recordersList;
nRetVal = context->getXnContext().EnumerateProductionTrees(XN_NODE_TYPE_RECORDER, NULL, recordersList);
START_CAPTURE_CHECK_RC(nRetVal, "Enumerate recorders");
// take first
NodeInfo chosen = *recordersList.Begin();
pRecorder = new Recorder;
nRetVal = context->getXnContext().CreateProductionTree(chosen, *pRecorder);
START_CAPTURE_CHECK_RC(nRetVal, "Create recorder");
nRetVal = pRecorder->SetDestination(XN_RECORD_MEDIUM_FILE, csFileName.c_str());
START_CAPTURE_CHECK_RC(nRetVal, "Set output file");
return true;
}
示例2: m_DepthGenerator
// Creates a DepthGenerator from Context
OpenNIDepthGenerator::OpenNIDepthGenerator(int num)
: m_DepthGenerator(NULL), m_Options(NULL)
{
XnStatus status = XN_STATUS_ERROR;
m_DepthGenerator = new DepthGenerator();
NodeInfoList l;
// enumerate depth generators
OpenNIContext::EnumerateProductionTrees(XN_NODE_TYPE_DEPTH, NULL , l);
int i = 0;
// look for generator according to number num
for (NodeInfoList::Iterator it = l.Begin(); it != l.End(); ++it, ++i){
if (i == num){
NodeInfo ni = *it;
status = OpenNIContext::CreateProductionTree(ni, *m_DepthGenerator);
}
}
if(i <= num){ // not enough generators
std::ostringstream s;
s << "Demanded depth generator nr " << num
<< " but only " << i << " available.";
DEBUG_LOG(s.str());
throw ICLException(s.str());
}
if (status != XN_STATUS_OK){ // error while creating depth generator
std::ostringstream s;
s << "Generator init error " << xnGetStatusString(status);
DEBUG_LOG(s.str());
throw ICLException(s.str());
}
// create GeneratorOptions for DepthGenerator
m_Options = new DepthGeneratorOptions(m_DepthGenerator);
m_DepthGenerator -> StartGenerating();
}
示例3: AddMember
int PNode :: AddMember(const int iGroupIdx, const NodeInfo & oNode)
{
if (!CheckGroupID(iGroupIdx))
{
return Paxos_GroupIdxWrong;
}
SystemVSM * poSystemVSM = m_vecGroupList[iGroupIdx]->GetConfig()->GetSystemVSM();
if (poSystemVSM->GetGid() == 0)
{
return Paxos_MembershipOp_NoGid;
}
uint64_t llVersion = 0;
NodeInfoList vecNodeInfoList;
poSystemVSM->GetMembership(vecNodeInfoList, llVersion);
for (auto & oNodeInfo : vecNodeInfoList)
{
if (oNodeInfo.GetNodeID() == oNode.GetNodeID())
{
return Paxos_MembershipOp_Add_NodeExist;
}
}
vecNodeInfoList.push_back(oNode);
return ProposalMembership(poSystemVSM, iGroupIdx, vecNodeInfoList, llVersion);
}
示例4: MakeConfig
void MakeConfig(MockLogStorage * poMockLogStorage, Config *& poConfig)
{
string sIP = "127.0.0.1";
int iPort = 11111;
NodeInfo oMyNode(sIP, iPort);
NodeInfoList vecNodeInfoList;
for (int i = 0; i < 3; i++)
{
vecNodeInfoList.push_back(NodeInfo(sIP, iPort));
iPort++;
}
FollowerNodeInfoList vecFollowerNodeInfoList;
int iMyGroupIdx = 0;
int iGroupCount = 1;
poConfig = nullptr;
poConfig = new Config(poMockLogStorage, true, 0, false, oMyNode, vecNodeInfoList, vecFollowerNodeInfoList, iMyGroupIdx, iGroupCount, nullptr);
assert(poConfig != nullptr);
EXPECT_CALL(*poMockLogStorage, GetSystemVariables(_,_)).Times(1).WillOnce(Return(1));
poConfig->Init();
}
示例5: OpenCommon
void SimKinect::OpenCommon()
{
XnStatus nRetVal = XN_STATUS_OK;
bIsDepthOn = false;
bIsImageOn = false;
bIsIROn = false;
bIsAudioOn = false;
bIsPlayerOn = false;
bIsUserOn = false;
NodeInfoList list;
nRetVal = context.EnumerateExistingNodes(list);
if (nRetVal == XN_STATUS_OK)
{
for (NodeInfoList::Iterator it = list.Begin(); it != list.End(); ++it)
{
switch ((*it).GetDescription().Type)
{
case XN_NODE_TYPE_DEVICE:
(*it).GetInstance(device);
break;
case XN_NODE_TYPE_DEPTH:
bIsDepthOn = true;
(*it).GetInstance(depth_generator);
break;
case XN_NODE_TYPE_IMAGE:
bIsImageOn = true;
(*it).GetInstance(color_generator);
break;
case XN_NODE_TYPE_IR:
bIsIROn = true;
(*it).GetInstance(ir_generator);
break;
case XN_NODE_TYPE_AUDIO:
bIsAudioOn = true;
(*it).GetInstance(audio_generator);
break;
case XN_NODE_TYPE_PLAYER:
bIsPlayerOn = true;
(*it).GetInstance(player);
break;
case XN_NODE_TYPE_USER :
bIsUserOn = true;
(*it).GetInstance(user_generator);
break;
}
}
}
XnCallbackHandle hDummy;
context.RegisterToErrorStateChange(onErrorStateChanged, NULL, hDummy);
}
示例6: captureOpenWriteDevice
bool captureOpenWriteDevice()
{
XnStatus nRetVal = XN_STATUS_OK;
NodeInfoList recordersList;
nRetVal = g_Context.EnumerateProductionTrees(XN_NODE_TYPE_RECORDER, NULL, recordersList);
START_CAPTURE_CHECK_RC(nRetVal, "Enumerate recorders");
// take first
NodeInfo chosen = *recordersList.Begin();
nRetVal = g_Context.CreateProductionTree(chosen);
START_CAPTURE_CHECK_RC(nRetVal, "Create recorder");
g_Capture.pRecorder = new Recorder;
nRetVal = chosen.GetInstance(*g_Capture.pRecorder);
START_CAPTURE_CHECK_RC(nRetVal, "Get recorder instance");
nRetVal = g_Capture.pRecorder->SetDestination(XN_RECORD_MEDIUM_FILE, g_Capture.csFileName);
START_CAPTURE_CHECK_RC(nRetVal, "Set output file");
if (getDevice() != NULL)
{
nRetVal = g_Capture.pRecorder->AddNodeToRecording(*getDevice(), XN_CODEC_UNCOMPRESSED);
START_CAPTURE_CHECK_RC(nRetVal, "add device node");
}
if (isDepthOn() && (g_Capture.DepthFormat != CODEC_DONT_CAPTURE))
{
nRetVal = g_Capture.pRecorder->AddNodeToRecording(*getDepthGenerator(), g_Capture.DepthFormat);
START_CAPTURE_CHECK_RC(nRetVal, "add depth node");
}
if (isImageOn() && (g_Capture.ImageFormat != CODEC_DONT_CAPTURE))
{
nRetVal = g_Capture.pRecorder->AddNodeToRecording(*getImageGenerator(), g_Capture.ImageFormat);
START_CAPTURE_CHECK_RC(nRetVal, "add image node");
}
if (isIROn() && (g_Capture.IRFormat != CODEC_DONT_CAPTURE))
{
nRetVal = g_Capture.pRecorder->AddNodeToRecording(*getIRGenerator(), g_Capture.IRFormat);
START_CAPTURE_CHECK_RC(nRetVal, "add IR stream");
}
if (isAudioOn() && (g_Capture.AudioFormat != CODEC_DONT_CAPTURE))
{
nRetVal = g_Capture.pRecorder->AddNodeToRecording(*getAudioGenerator(), g_Capture.AudioFormat);
START_CAPTURE_CHECK_RC(nRetVal, "add Audio stream");
}
return true;
}
示例7: openCommon
void openCommon()
{
XnStatus nRetVal = XN_STATUS_OK;
g_bIsDepthOn = false;
g_bIsImageOn = false;
g_bIsIROn = false;
g_bIsAudioOn = false;
g_bIsPlayerOn = false;
NodeInfoList list;
nRetVal = g_Context.EnumerateExistingNodes(list);
if (nRetVal == XN_STATUS_OK)
{
for (NodeInfoList::Iterator it = list.Begin(); it != list.End(); ++it)
{
switch ((*it).GetDescription().Type)
{
case XN_NODE_TYPE_DEVICE:
(*it).GetInstance(g_Device);
break;
case XN_NODE_TYPE_DEPTH:
g_bIsDepthOn = true;
(*it).GetInstance(g_Depth);
break;
case XN_NODE_TYPE_IMAGE:
g_bIsImageOn = true;
(*it).GetInstance(g_Image);
break;
case XN_NODE_TYPE_IR:
g_bIsIROn = true;
(*it).GetInstance(g_IR);
break;
case XN_NODE_TYPE_AUDIO:
g_bIsAudioOn = true;
(*it).GetInstance(g_Audio);
break;
case XN_NODE_TYPE_PLAYER:
g_bIsPlayerOn = true;
(*it).GetInstance(g_Player);
}
}
}
XnCallbackHandle hDummy;
g_Context.RegisterToErrorStateChange(onErrorStateChanged, NULL, hDummy);
initConstants();
readFrame();
}
示例8: parse_ipport_list
int parse_ipport_list(const char * pcStr, NodeInfoList & vecNodeInfoList)
{
string sTmpStr;
int iStrLen = strlen(pcStr);
for (int i = 0; i < iStrLen; i++)
{
if (pcStr[i] == ',' || i == iStrLen - 1)
{
if (i == iStrLen - 1 && pcStr[i] != ',')
{
sTmpStr += pcStr[i];
}
NodeInfo oNodeInfo;
int ret = parse_ipport(sTmpStr.c_str(), oNodeInfo);
if (ret != 0)
{
return ret;
}
vecNodeInfoList.push_back(oNodeInfo);
sTmpStr = "";
}
else
{
sTmpStr += pcStr[i];
}
}
return 0;
}
示例9: ChangeMember
int PNode :: ChangeMember(const int iGroupIdx, const NodeInfo & oFromNode, const NodeInfo & oToNode)
{
if (!CheckGroupID(iGroupIdx))
{
return Paxos_GroupIdxWrong;
}
SystemVSM * poSystemVSM = m_vecGroupList[iGroupIdx]->GetConfig()->GetSystemVSM();
if (poSystemVSM->GetGid() == 0)
{
return Paxos_MembershipOp_NoGid;
}
uint64_t llVersion = 0;
NodeInfoList vecNodeInfoList;
poSystemVSM->GetMembership(vecNodeInfoList, llVersion);
NodeInfoList vecAfterNodeInfoList;
bool bFromNodeExist = false;
bool bToNodeExist = false;
for (auto & oNodeInfo : vecNodeInfoList)
{
if (oNodeInfo.GetNodeID() == oFromNode.GetNodeID())
{
bFromNodeExist = true;
continue;
}
else if (oNodeInfo.GetNodeID() == oToNode.GetNodeID())
{
bToNodeExist = true;
continue;
}
vecAfterNodeInfoList.push_back(oNodeInfo);
}
if ((!bFromNodeExist) && bToNodeExist)
{
return Paxos_MembershipOp_Change_NoChange;
}
vecAfterNodeInfoList.push_back(oToNode);
return ProposalMembership(poSystemVSM, iGroupIdx, vecAfterNodeInfoList, llVersion);
}
示例10: captureOpenWriteDevice
bool captureOpenWriteDevice()
{
XnStatus nRetVal = XN_STATUS_OK;
NodeInfoList recordersList;
nRetVal = g_Context.EnumerateProductionTrees(XN_NODE_TYPE_RECORDER, NULL, recordersList);
START_CAPTURE_CHECK_RC(nRetVal, "Enumerate recorders");
// take first
NodeInfo chosen = *recordersList.Begin();
g_Capture.pRecorder = new Recorder;
nRetVal = g_Context.CreateProductionTree(chosen, *g_Capture.pRecorder);
START_CAPTURE_CHECK_RC(nRetVal, "Create recorder");
nRetVal = g_Capture.pRecorder->SetDestination(XN_RECORD_MEDIUM_FILE, g_Capture.csFileName);
START_CAPTURE_CHECK_RC(nRetVal, "Set output file");
return true;
}
示例11: m_IrGenerator
// Creates a IrGenerator from Context
OpenNIIRGenerator::OpenNIIRGenerator(int num)
: m_IrGenerator(NULL), m_Options(NULL)
{
XnStatus status = XN_STATUS_ERROR;
m_IrGenerator = new IRGenerator();
NodeInfoList l;
// enumerate ir generators
OpenNIContext::EnumerateProductionTrees(XN_NODE_TYPE_IR, NULL , l);
int i = 0;
// create generator according to num
for (NodeInfoList::Iterator it = l.Begin(); it != l.End(); ++it, ++i){
if (i == num){
NodeInfo ni = *it;
status = OpenNIContext::CreateProductionTree(ni, *m_IrGenerator);
}
}
if(i <= num){ // not enough generators
std::ostringstream s;
s << "Demanded ir generator nr " << num
<< " but only " << i << " available.";
DEBUG_LOG(s.str());
throw ICLException(s.str());
}
if (XN_STATUS_OK != status){ // error while creating generator
std::string error = xnGetStatusString(status);
DEBUG_LOG("IRGenerator init error '" << error << "'");
throw new ICLException(error);
}
// somehow my kinect did not create the ir images before setting it to
// this MapOutputMode.
XnMapOutputMode mo;
mo.nFPS = 30;
mo.nXRes = 640;
mo.nYRes = 480;
m_IrGenerator -> SetMapOutputMode(mo);
// create generator options
m_Options = new MapGeneratorOptions(m_IrGenerator);
status = m_IrGenerator -> StartGenerating();
DEBUG_LOG2("startgenerating: " << xnGetStatusString(status));
}
示例12: m_RgbGenerator
// Creates a RgbGenerator from Context
OpenNIRgbGenerator::OpenNIRgbGenerator(int num)
: m_RgbGenerator(NULL), m_Options(NULL)
{
XnStatus status;
// create DepthGenerator. The Kinect rgb-generator did not work without
// a depth generator being initialized beforehand.
m_DepthGenerator = new DepthGenerator();
if (XN_STATUS_OK != (status = OpenNIContext::Create(m_DepthGenerator))){
std::string error = xnGetStatusString(status);
DEBUG_LOG("DepthGenerator init error '" << error << "'");
throw new ICLException(error);
}
m_RgbGenerator = new ImageGenerator();
NodeInfoList l;
// get all rgb-image generators
OpenNIContext::EnumerateProductionTrees(XN_NODE_TYPE_IMAGE, NULL , l);
int i = 0;
// create generator according to num
for (NodeInfoList::Iterator it = l.Begin(); it != l.End(); ++it, ++i){
if (i == num){
NodeInfo ni = *it;
status = OpenNIContext::CreateProductionTree(ni, *m_RgbGenerator);
}
}
if(i <= num){ // not enough generators found
std::ostringstream s;
s << "Demanded rgb generator nr " << num
<< " but only " << i << " available.";
DEBUG_LOG(s.str());
throw ICLException(s.str());
}
if (status != XN_STATUS_OK){ // error while creating
std::string error = xnGetStatusString(status);
DEBUG_LOG("ImageGenerator init error '" << error << "'");
throw new ICLException(error);
}
// create generator options
m_Options = new ImageGeneratorOptions(m_RgbGenerator);
m_RgbGenerator -> StartGenerating();
DEBUG_LOG2("done creating OpenNIRgbGenerator");
}
示例13: Connect
bool KinectCamera::Connect(int index)
{
m_index = index;
XnStatus rc;
EnumerationErrors errors;
rc = context.Init();
NodeInfoList list;
rc = context.EnumerateProductionTrees(XN_NODE_TYPE_DEVICE, NULL, list, &errors);
int i = 0;
for (NodeInfoList::Iterator it = list.Begin(); it != list.End(); ++it, ++i)
{
if(i == index)
{
printf("%d\n", i);
NodeInfo deviceNodeInfo = *it;
context.CreateProductionTree(deviceNodeInfo);
rc |= depth.Create(context);
rc |= image.Create(context);
XnMapOutputMode m;
m.nXRes = 640;
m.nYRes = 480;
image.SetMapOutputMode(m);
rc |= context.StartGeneratingAll();
break;
}
}
if(i != index)
{
return false;
}
printf("Success: %d\n", rc);
return true;
}
示例14: EnumerateProductionTrees
XnStatus ExportedCodec::EnumerateProductionTrees(Context& context, NodeInfoList& TreesList, xn::EnumerationErrors* pErrors)
{
XnStatus nRetVal = XN_STATUS_OK;
XnProductionNodeDescription desc;
GetDescription(&desc);
nRetVal = TreesList.Add(desc, NULL, NULL);
XN_IS_STATUS_OK(nRetVal);
return (XN_STATUS_OK);
}
示例15: GetMembership
void SystemVSM :: GetMembership(NodeInfoList & vecNodeInfoList, uint64_t & llVersion)
{
//must must get version first!
llVersion = m_oSystemVariables.version();
for (int i = 0; i < m_oSystemVariables.membership_size(); i++)
{
PaxosNodeInfo oNodeInfo = m_oSystemVariables.membership(i);
NodeInfo tTmpNode(oNodeInfo.nodeid());
vecNodeInfoList.push_back(tTmpNode);
}
}