本文整理汇总了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;
}
}
示例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)
//.........这里部分代码省略.........