當前位置: 首頁>>代碼示例>>C#>>正文


C# Context.CreateProductionTree方法代碼示例

本文整理匯總了C#中OpenNI.Context.CreateProductionTree方法的典型用法代碼示例。如果您正苦於以下問題:C# Context.CreateProductionTree方法的具體用法?C# Context.CreateProductionTree怎麽用?C# Context.CreateProductionTree使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenNI.Context的用法示例。


在下文中一共展示了Context.CreateProductionTree方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Open

        void Open(int i)
		{
			try
			{
				Close(i);


                OpenNIState state = FState[i];
                var context = new Context();
				FState[i].Context = context;
                context.AddLicense(FLicense);
                context.GlobalMirror = false;


                NodeInfoList list = context.EnumerateProductionTrees(global::OpenNI.NodeType.Device, null);
                NodeInfo node = null;
                if (FPinInNodes[i] != "")
                {
                    foreach (NodeInfo nodeitem in list)
                    {
                        if (nodeitem.CreationInfo == FPinInNodes[i])
                        {
                            node = nodeitem;
                            break;
                        }
                    }

                    if (node == null)
                        throw (new Exception("This device is unavailable. Check upstream ListDevices node"));

                    context.CreateProductionTree(node);
                }

                state.DepthGenerator = new DepthGenerator(context);
                MapOutputMode depthMode = new MapOutputMode();
                depthMode.FPS = 30;
                depthMode.XRes = 640;
                depthMode.YRes = 480;
                state.DepthGenerator.MapOutputMode = depthMode;
                state.DepthGenerator.StartGenerating();

                state.Start();

                FPinOutContext[i] = state;
                FPinOutStatus[i] = "OK";
			}
			catch (Exception e)
			{
				Close(i);
				FPinOutStatus[i] = e.Message;
			}
		}
開發者ID:smakhtin,項目名稱:VVVV.Nodes.Image,代碼行數:52,代碼來源:ContextNode.cs

示例2: Initialize

		public void Initialize()
		{
			//Dispose();

			try
			{
				m_MasterContext = new Context();

				NodeInfoList deviceList = m_MasterContext.EnumerateProductionTrees(NodeType.Device, null);

				int deviceCount = 0;
				foreach (NodeInfo nodeInfo in deviceList)
				{
					deviceCount++;
					/* 
					RC.WriteLine("Device: " + nodeInfo.InstanceName);
					RC.WriteLine("Node: " + nodeInfo.CreationInfo);
					RC.WriteLine("Name: " + nodeInfo.Description.Name.ToString());
					RC.WriteLine("Vendor: " + nodeInfo.Description.Vendor.ToString());
					RC.WriteLine("Version: " + nodeInfo.Description.Version.ToString());
					RC.WriteLine("");
					*/
				}

				RC.WriteLine(ConsoleThemeColor.TitleText1, deviceCount + " Kinect Devices Detected");

				NodeInfoList depthList = m_MasterContext.EnumerateProductionTrees(NodeType.Depth, null);

				int depthSourceCount = 0;
				foreach (NodeInfo nodeInfo in depthList)
				{
					depthSourceCount++;
					/* 
					RC.WriteLine("Depth Image Source: " + nodeInfo.InstanceName);
					RC.WriteLine("Node: " + nodeInfo.CreationInfo);
					RC.WriteLine("Name: " + nodeInfo.Description.Name.ToString());
					RC.WriteLine("Vendor: " + nodeInfo.Description.Vendor.ToString());
					RC.WriteLine("Version: " + nodeInfo.Description.Version.ToString());
					RC.WriteLine("");
					*/
				}

				RC.WriteLine(ConsoleThemeColor.TitleText1, depthSourceCount + " Depth Image Sources Detected");


				int deviceIndex = 0;

				foreach (NodeInfo nodeInfo in depthList)
				{
					DepthGenerator depth = m_MasterContext.CreateProductionTree(nodeInfo) as DepthGenerator;

					if (depth == null)
					{
						throw new Exception("Viewer must have a depth node!");
					}

					//MapOutputMode requiredMode = new MapOutputMode() { FPS = 30, XRes = 320, YRes = 240 };

					//depth.MapOutputMode = requiredMode;
					RC.WriteLine(ConsoleThemeColor.TitleText1, "Device: " + deviceIndex);
					/* 
					MapOutputMode selectedMode = depth.MapOutputMode; 

					foreach (MapOutputMode mode in depth.GetSupportedMapOutputModes())
					{
						RC.WriteLine(ConsoleThemeColor.Text1, "Mode:" + mode.XRes + "x" + mode.YRes + ", " + mode.FPS + " FPS");

						if (mode.XRes == 320 && mode.YRes == 240 && mode.FPS == 60)
						{
							selectedMode = mode;
						}
					}
				
					depth.MapOutputMode = selectedMode; 

					MapOutputMode mapMode = depth.MapOutputMode;
					*/

					ImageResolution ColorResolution = ImageResolution.Invalid;
					ImageResolution DepthResolution = ImageResolution.Resolution320x240;

					/* if (mapMode.XRes == 320 && mapMode.YRes == 240)
					{
						DepthResolution = ImageResolution.Resolution320x240;
					}
					else if (mapMode.XRes == 640 && mapMode.YRes == 480)
					{
						DepthResolution = ImageResolution.Resolution640x480;
					}
					else
					{
						DepthResolution = ImageResolution.Invalid;
					}
					 * */

					Devices.Add(new KinectDevice(deviceIndex++, depth, DepthResolution, ColorResolution));
				}

			}
			catch (Exception ex)
//.........這裏部分代碼省略.........
開發者ID:RugCode,項目名稱:drg-pt,代碼行數:101,代碼來源:KinectDeviceMaster.cs


注:本文中的OpenNI.Context.CreateProductionTree方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。