//Starts up necessary files to take data //Must run before TakeData() Kinect() { //Sets locations of XML File string SAMPLE_XML_FILE = @"..\\..\\..\\SamplesConfig.xml"; //Declares object of ScriptNode and defines context ScriptNode scriptNode; context = Context.CreateFromXmlFile(SAMPLE_XML_FILE, out scriptNode); //Declares the depth generator depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator; //If the depth generator does not exist returns error messag if (depth == null) { Console.WriteLine("Sample must have a depth generator!"); Console.ReadLine(); return; } //Declares necessary variables and classes to take depth //DepthGenerator depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator; mapMode = depth.MapOutputMode; depthMD = new DepthMetaData(); }
public KinectManager(InputProvider inputProvider) { this.inputProvider = inputProvider; //get configuration String OpenNiconfigPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + CONFIG_XML_FILE; this.context = Context.CreateFromXmlFile(OpenNiconfigPath, out scriptNode); this.depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator; if (this.depth == null) { throw new Exception("Viewer must have a depth node!"); } this.maxDepth = this.depth.DeviceMaxDepth; this.userGenerator = new UserGenerator(this.context); this.skeletonCapbility = this.userGenerator.SkeletonCapability; this.poseDetectionCapability = this.userGenerator.PoseDetectionCapability; this.calibPose = this.skeletonCapbility.CalibrationPose; this.userGenerator.NewUser += userGenerator_NewUser; this.userGenerator.LostUser += userGenerator_LostUser; this.poseDetectionCapability.PoseDetected += poseDetectionCapability_PoseDetected; this.skeletonCapbility.CalibrationComplete += skeletonCapbility_CalibrationComplete; this.skeletonCapbility.SetSkeletonProfile(SkeletonProfile.Upper); this.users = new Dictionary<int, User>(); this.userGenerator.StartGenerating(); this.mapMode = this.depth.MapOutputMode; //load settings updateSettings(); //start threads this.shouldRun = true; this.readerThread = new Thread(ReaderThread); this.readerThread.Start(); this.settingsUpdateThread = new Thread(runUpdateSettings); this.settingsUpdateThread.Start(); Console.WriteLine("Device initialized"); }
private string InitialiseImage() { string messages = ""; MapOutputMode imageMode = new MapOutputMode(); imageMode.XRes = FSize.Width; imageMode.YRes = FSize.Height; imageMode.FPS = 30; if (Mode == ImageNodeMode.RGB) { if (FIRGenerator != null) { FIRGenerator.StopGenerating(); FIRGenerator.Dispose(); } FRGBGenerator = new ImageGenerator(FState.Context); FRGBGenerator.MapOutputMode = imageMode; Image.Image.Initialise(FSize, TColorFormat.RGB8); if (FState.DepthGenerator.AlternativeViewpointCapability.IsViewpointSupported(FRGBGenerator)) { FState.DepthGenerator.AlternativeViewpointCapability.SetViewpoint(FRGBGenerator); } else { messages += "AlternativeViewportCapability not supported\n"; } FRGBGenerator.StartGenerating(); } else { if (FRGBGenerator != null) { FRGBGenerator.StopGenerating(); FRGBGenerator.Dispose(); } FIRGenerator = new IRGenerator(FState.Context); FIRGenerator.MapOutputMode = imageMode; FIRGenerator.StartGenerating(); Image.Image.Initialise(FSize, TColorFormat.L16); } return messages; }
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; } }
public void AddSupportedMapOutputMode(MapOutputMode mode) { int status = SafeNativeMethods.xnNodeQueryAddSupportedMapOutputMode(this.InternalObject, ref mode); WrapperUtils.ThrowOnError(status); }
public static extern XnStatus xnSetMapOutputMode(XnNodeHandle hInstance, ref MapOutputMode pOutputMode);
public static extern XnStatus xnNodeQueryAddSupportedMapOutputMode(XnNodeQuery pQuery, ref MapOutputMode pMapOutputMode);