EnumerateProductionTrees() public method

public EnumerateProductionTrees ( NodeType type ) : NodeInfoList
type NodeType
return NodeInfoList
コード例 #1
0
        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;
			}
		}
コード例 #2
0
ファイル: KinectDeviceMaster.cs プロジェクト: RugCode/drg-pt
		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)
			{
				RC.WriteException(666, "Failed to start OpenNI", ex); 
			}

			if (Devices.Count > 0)
			{
				this.m_ShouldRun = true;

				this.m_ReaderThread = new Thread(ReaderThread);
				this.m_ReaderThread.Start();
			}
			else
			{
				Devices.Add(new KinectDevice(0, DepthResolution, ColorResolution));	
			}

		}