当前位置: 首页>>代码示例>>C++>>正文


C++ Context::CreateProductionTree方法代码示例

本文整理汇总了C++中Context::CreateProductionTree方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::CreateProductionTree方法的具体用法?C++ Context::CreateProductionTree怎么用?C++ Context::CreateProductionTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Context的用法示例。


在下文中一共展示了Context::CreateProductionTree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OneKinect

void OneKinect(int type)
{
	NodeInfoList image_node_info_list;
	NodeInfoList depth_node_info_list;
	XnStatus status;
	Context context;
	int c;
	IplImage* kinectRGBImage;
	bool bShouldrun = true;

	context.Init();
//	status = context.InitFromXmlFile("D:\\initXml.xml");
	Query query;
	
	switch (type) {

	case 0: 
		status = query.SetVendor("PrimeSense");
		status = context.EnumerateProductionTrees(XN_NODE_TYPE_DEPTH, &query, depth_node_info_list, NULL);
		//status = context.EnumerateProductionTrees(XN_NODE_TYPE_DEPTH, NULL, depth_node_info_list, NULL);
		if (status != XN_STATUS_OK)
			printf("Enumerating devices failed. Reason: %s", xnGetStatusString(status));
		else
		{
			NodeInfoList::Iterator nodeIt = depth_node_info_list.Begin();
//			NodeInfo& selectedNode = *depth_node_info_list.Begin();
//			nodeIt++;
			
			NodeInfo& selectedNode = *nodeIt;

			printf("instance %s\n", selectedNode.GetInstanceName());

			DepthGenerator depth;
			status = selectedNode.GetInstance(depth);
			status = context.CreateProductionTree(selectedNode);
			status = depth.Create(context);
			status = context.StartGeneratingAll();
			cvNamedWindow("Depth", 1);

			// Create an OpenCv matrix
			CvMat* depthMetersMat = cvCreateMat(480, 640, CV_16UC1);
			IplImage *kinectDepthImage;

			while (bShouldrun)
			{
				status = context.WaitOneUpdateAll(depth);
				if (status)
				{
					printf("Error: %s", xnGetStatusString(status));
					continue;
				}
				//Take current depth map
				const XnDepthPixel* pDepthMap = depth.GetDepthMap();
				for (int y=0; y<XN_VGA_Y_RES; y++)
				{
					for (int x=0; x<XN_VGA_X_RES; x++)
					{
						depthMetersMat->data.s[y*XN_VGA_X_RES+x]=10*pDepthMap[y*XN_VGA_X_RES+x];
					}
				}
				kinectDepthImage = cvCreateImage(cvSize(640,480),8,1);
				cvGetImage(depthMetersMat, kinectDepthImage);
				cvShowImage("Depth", kinectDepthImage);
				cvReleaseImageHeader(&kinectDepthImage);
				c = cvWaitKey(1);
				if (c == 27)
					bShouldrun = false;
			}

		}
		break;
		
	case 1:
		status = context.EnumerateProductionTrees(XN_NODE_TYPE_IMAGE, NULL, image_node_info_list, NULL); 
		if (status != XN_STATUS_OK)
			printf("Enumerating devices failed. Reason: %s", xnGetStatusString(status));
		else
		{
			NodeInfo& selectedNode = *image_node_info_list.Begin();
			xn::ImageGenerator rgb;
			status = selectedNode.GetInstance(rgb);
			status = context.CreateProductionTree(selectedNode);
			status = rgb.Create(context);
			
			status = context.StartGeneratingAll();
			cvNamedWindow("RGB", 1);

			while (bShouldrun)
			{
				kinectRGBImage = cvCreateImage(cvSize(640,480),8,3);
				// Wait for new data to be available
				status = context.WaitOneUpdateAll(rgb);
				if (status != XN_STATUS_OK)
				{
					printf("Failed updating data: %s\n");
					xnGetStatusString(status);
					continue;
				}
				// Take current rgb map
				const XnRGB24Pixel* pImageMap = rgb.GetRGB24ImageMap();
//.........这里部分代码省略.........
开发者ID:pechu40,项目名称:HelloKinect,代码行数:101,代码来源:helloKinect.cpp

示例2: openDeviceFromXmlWithChoice

XnStatus openDeviceFromXmlWithChoice(const char* csXmlFile, EnumerationErrors& errors)
{
	XnStatus nRetVal = XN_STATUS_OK;

	xnLogInitFromXmlFile(csXmlFile);

	nRetVal = g_Context.Init();
	XN_IS_STATUS_OK(nRetVal);

	// find devices
	NodeInfoList list;
	nRetVal = g_Context.EnumerateProductionTrees(XN_NODE_TYPE_DEVICE, NULL, list, &errors);
	XN_IS_STATUS_OK(nRetVal);

	printf("The following devices were found:\n");
	int i = 1;
	for (NodeInfoList::Iterator it = list.Begin(); it != list.End(); ++it, ++i)
	{
		NodeInfo deviceNodeInfo = *it;

		Device deviceNode;
		deviceNodeInfo.GetInstance(deviceNode);
		XnBool bExists = deviceNode.IsValid();
		if (!bExists)
		{
			g_Context.CreateProductionTree(deviceNodeInfo, deviceNode);
			// this might fail.
		}

		if (deviceNode.IsValid() && deviceNode.IsCapabilitySupported(XN_CAPABILITY_DEVICE_IDENTIFICATION))
		{
			const XnUInt32 nStringBufferSize = 200;
			XnChar strDeviceName[nStringBufferSize];
			XnChar strSerialNumber[nStringBufferSize];

			XnUInt32 nLength = nStringBufferSize;
			deviceNode.GetIdentificationCap().GetDeviceName(strDeviceName, nLength);
			nLength = nStringBufferSize;
			deviceNode.GetIdentificationCap().GetSerialNumber(strSerialNumber, nLength);
			printf("[%d] %s (%s)\n", i, strDeviceName, strSerialNumber);
		}
		else
		{
			printf("[%d] %s\n", i, deviceNodeInfo.GetCreationInfo());
		}

		// release the device if we created it
		if (!bExists && deviceNode.IsValid())
		{
			deviceNode.Release();
		}
	}
	printf("\n");
	printf("Choose device to open (1): ");

	int chosen = 1;
	scanf("%d", &chosen);

	// create it
	NodeInfoList::Iterator it = list.Begin();
	for (i = 1; i < chosen; ++i)
	{
		it++;
	}

	NodeInfo deviceNode = *it;
	nRetVal = g_Context.CreateProductionTree(deviceNode, g_Device);
	XN_IS_STATUS_OK(nRetVal);

	// now run the rest of the XML
	nRetVal = g_Context.RunXmlScriptFromFile(csXmlFile, g_scriptNode, &errors);
	XN_IS_STATUS_OK(nRetVal);

	openCommon();

	return (XN_STATUS_OK);
}
开发者ID:mpweinge,项目名称:KinectHandTracker,代码行数:77,代码来源:Device.cpp

示例3: record


//.........这里部分代码省略.........
        nDepths++;
    }

    //Show RGB Devices
    if(record_rgb){
        //RGB devices
        i = 0;
        for (xn::NodeInfoList::Iterator nodeIt = img_nodes.Begin(); nodeIt != img_nodes.End(); ++nodeIt, i++) {
            NodeInfo info = *nodeIt;
            const XnProductionNodeDescription& description = info.GetDescription();
            qDebug("RGB: vendor %s name %s, instance %s",description.strVendor,description.strName, info.GetInstanceName());
            nImg++;
        }

    }

    //Init everything
    i=0;
    char date[20];
    strcpy(date,QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss").toLocal8Bit());
    qDebug() << date;

    //Init depth devices & 'recorders'
    DepthGenerator depthaux[MAXGENERATORS];
    Recorder recorderaux[MAXGENERATORS];

    for (xn::NodeInfoList::Iterator nodeIt = depth_nodes.Begin(); nodeIt != depth_nodes.End(); ++nodeIt, i++) {
        //DepthGenerator depthaux;
        //Recorder recorderaux;
        XNFiles AuxFile;
        NodeInfo info = *nodeIt;
        const XnProductionNodeDescription& description = info.GetDescription();

        nRetVal = context.CreateProductionTree(info,depthaux[i]);
        nRetVal = info.GetInstance(depthaux[i]);
        qDebug("Instance Name %s",info.GetInstanceName());

        XnFieldOfView field;
        nRetVal= depthaux[i].GetFieldOfView(field);

        DepthsGen[i]=depthaux[i];
        qDebug("Depth Generator %i", i);

        Recorders[i]=recorderaux[i];
        nRetVal = Recorders[i].Create(context);

        XnChar recording_fileXnaux[300];
        strcpy(recording_fileXnaux,QDir::currentPath().toLocal8Bit());

        if(record_rgb)
            sprintf(recording_fileXnaux,"%s%s%s%d%s%s.oni",recording_fileXnaux,"/","DC-",i,"_",date);
        else
            sprintf(recording_fileXnaux,"%s%s%s%d%s%s.oni",recording_fileXnaux,"/","D-",i,"_",date);

        strcpy(AuxFile.name,recording_fileXnaux);
        qDebug(AuxFile.name);

        nRetVal = Recorders[i].SetDestination(XN_RECORD_MEDIUM_FILE,recording_fileXnaux);
        nRetVal = Recorders[i].AddNodeToRecording(DepthsGen[i], XN_CODEC_16Z_EMB_TABLES);
    }

    //Init RGB devices
    if(record_rgb){
        i=0;
        ImageGenerator imgaux[MAXGENERATORS];
开发者ID:Sahloul,项目名称:simple-kinect-record-openni,代码行数:66,代码来源:recorder.cpp


注:本文中的Context::CreateProductionTree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。