private static void Main() { Console.WriteLine(OpenNI.Version.ToString()); OpenNI.Status status = OpenNI.Initialize(); if (!HandleError(status)) { Environment.Exit(0); } OpenNI.OnDeviceConnected += OpenNiOnDeviceConnected; OpenNI.OnDeviceDisconnected += OpenNiOnDeviceDisconnected; DeviceInfo[] devices = OpenNI.EnumerateDevices(); if (devices.Length == 0) { return; } Device device; // lean init and no reset flags using (device = Device.Open(null, "lr")) { if (device.HasSensor(Device.SensorType.Depth) && device.HasSensor(Device.SensorType.Color)) { VideoStream depthStream = device.CreateVideoStream(Device.SensorType.Depth); VideoStream colorStream = device.CreateVideoStream(Device.SensorType.Color); if (depthStream.IsValid && colorStream.IsValid) { if (!HandleError(depthStream.Start())) { OpenNI.Shutdown(); return; } if (!HandleError(colorStream.Start())) { OpenNI.Shutdown(); return; } new Thread(DisplayInfo).Start(); depthStream.OnNewFrame += DepthStreamOnNewFrame; colorStream.OnNewFrame += ColorStreamOnNewFrame; VideoStream[] array = { depthStream, colorStream }; while (!Console.KeyAvailable) { VideoStream aS; if (OpenNI.WaitForAnyStream(array, out aS) == OpenNI.Status.Ok) { if (aS.Equals(colorStream)) { inlineColor++; } else { inlineDepth++; } aS.ReadFrame().Release(); } } } } Console.ReadLine(); } OpenNI.Shutdown(); Environment.Exit(0); }