private void OpenNI2_OpenDevice() { DeviceInfo[] devices = OpenNI.EnumerateDevices(); if (devices.Length > 0) { this.mDevice = devices[0].OpenDevice(); if (this.mDevice != null && this.mDevice.IsValid) { this.strDevice = string.Format("Device {0} is now connected and opened.\n", devices[0].Name); this.bIsDeviceOpened = true; } else { this.strDevice = "Sorry. Available device NOT found.\n"; this.bIsDeviceOpened = false; } } else { this.strDevice = "Sorry. Available device NOT found.\n"; this.bIsDeviceOpened = false; } this.Dispatcher.Invoke((Action)(() => { this.txtDevice.Text = this.strDevice; })); }
private void UpdateDevicesList() { var devices = OpenNI.EnumerateDevices(); cb_device.Items.Clear(); if (devices.Length == 0) { cb_device.Items.Add("None"); } var inList = false; foreach (var device in devices) { cb_device.Items.Add(device); if (device.Uri == Settings.Default.DeviceURI) { inList = true; } } if (!inList) { Settings.Default.DeviceURI = string.Empty; } if (cb_device.SelectedIndex == -1) { cb_device.SelectedIndex = 0; } }
private void UpdateDevicesList() { DeviceInfo[] devices = OpenNI.EnumerateDevices(); this.cb_devices.Items.Clear(); foreach (DeviceInfo device in devices) { this.cb_devices.Items.Add(device); } }
public static void Initialize() { OpenNI.Shutdown();//例外などで前回シャットダウンされなかった場合用 OpenNI.Initialize(); NiTE.Initialize(); ConnectedDevices = OpenNI.EnumerateDevices(); OpenNI.OnDeviceConnected += OpenNI_onDeviceConnected; OpenNI.OnDeviceDisconnected += OpenNI_onDeviceConnected; OpenNI.OnDeviceStateChanged += OpenNI_onDeviceStateChanged; Instance = new OpenNIManager(); }
private void UpdateDevicesList() { var devices = OpenNI.EnumerateDevices(); cb_devices.Items.Clear(); foreach (var device in devices) { cb_devices.Items.Add(device); } }
private DeviceInfo updateDeviceList(string deviceName) { DeviceInfo[] devices = OpenNI.EnumerateDevices(); Console.WriteLine("Scanning for new devices..."); foreach (var device in devices) { Console.WriteLine("New devices found: " + device); if (device.ToString().Equals(deviceName)) { return(device); } } return(null); }
private void UpdateDevicesList() { DeviceInfo[] devices = OpenNI.EnumerateDevices(); this.cb_devices.Items.Clear(); this.cb_devices.Items.Add("None"); this.cb_devices.Enabled = devices.Length != 0; foreach (DeviceInfo device in devices) { this.cb_devices.Items.Add(device); } if (this.cb_devices.Items.Count > 0) { this.cb_devices.SelectedIndex = 0; } }
// Start is called before the first frame update void Start() { OpenNI.Initialize(); OpenNI.OnDeviceConnected += OnDeviceConnectionStateChanged; OpenNI.OnDeviceDisconnected += OnDeviceConnectionStateChanged; var devices = OpenNI.EnumerateDevices(); Debug.Log($"Found {devices.Length} devices"); // foreach (var d in devices) { // Debug.Log(d.Name); // } // connect to first one if (devices.Length > 0) { OnDeviceConnectionStateChanged(devices[0]); } }
public KinectOpenNi2() { HandleError(OpenNI.Initialize()); DeviceInfo[] devices = OpenNI.EnumerateDevices(); if (devices.Length == 0) { HandleError(OpenNI.Status.NO_DEVICE); } kinectDevice = devices[0].OpenDevice(); colorSensor = kinectDevice.CreateVideoStream(Device.SensorType.COLOR); VideoMode[] videoModes = colorSensor.SensorInfo.getSupportedVideoModes(); colorSensor.VideoMode = videoModes[1]; colorSensor.Start(); colorSensor.onNewFrame += new VideoStream.VideoStreamNewFrame(colorSensor_onNewFrame); depthSensor = kinectDevice.CreateVideoStream(Device.SensorType.DEPTH); videoModes = depthSensor.SensorInfo.getSupportedVideoModes(); depthSensor.VideoMode = videoModes[0]; depthSensor.Start(); depthSensor.onNewFrame += new VideoStream.VideoStreamNewFrame(depthSensor_onNewFrame); }
static void OpenNI_onDeviceConnected(DeviceInfo Device) { ConnectedDevices = OpenNI.EnumerateDevices(); }
static void OpenNI_onDeviceStateChanged(DeviceInfo Device, OpenNI.DeviceState state) { ConnectedDevices = OpenNI.EnumerateDevices(); }
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); }