public void Connect() { sensor = new NuiSensor(); SetCommand(NUISENSOR_RGB_COMMAND_TYPE.NUISENSOR_RGB_COMMAND_SET_ACS, 0u); Task.Delay(500).Wait(); SetCommand(NUISENSOR_RGB_COMMAND_TYPE.NUISENSOR_RGB_COMMAND_SET_EXPOSURE_MODE, 3u); }
/// <summary> /// Handles the nui sensor connected /// </summary> /// <param name="sensor">connected sensor</param> void nuiApp_OnSensorConnected(NuiSensor sensor) { if (useSensor == null) { //set usesensor to now connected sensor when usesensor is empty useSensor = sensor; //open color frame useSensor.OpenColorFrame(); //use invoke for access to the this wpf window's ui Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { //create bitmap instance bitmap = new WriteableBitmap( useSensor.ColorInfo.Width, useSensor.ColorInfo.Height, 96, 96, PixelFormats.Bgra32, null); //set the colorImage's source to colorframe's bitmap colorImage.Source = bitmap; //update sensor's name,vendor textbox sensorNameTB.Text = useSensor.Name; sensorVendorTB.Text = useSensor.Vendor; })); } }
/// <summary> /// Handles the nui sensor connected /// </summary> /// <param name="sensor">connected sensor</param> void nuiApp_OnSensorConnected(NuiSensor sensor) { if (useSensor == null) { //set usesensor to now connected sensor when usesensor is empty useSensor = sensor; // allocate space to put the pixels being received and converted depthPixels = new byte[useSensor.DepthInfo.Width * useSensor.DepthInfo.Height]; //open depth frame useSensor.OpenDepthFrame(); //use invoke for access to the this wpf window's ui Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { //create bitmap instance bitmap = new WriteableBitmap(useSensor.DepthInfo.Width, useSensor.DepthInfo.Height, 96.0, 96.0, PixelFormats.Gray8, null); //set the depthImage's source to depthframe's bitmap depthImage.Source = bitmap; //update sensor's name,vendor textbox sensorNameTB.Text = useSensor.Name; sensorVendorTB.Text = useSensor.Vendor; })); } }
private void Disconnect() { if (sensor != null) { sensor.Dispose(); sensor = null; } }
public ColorChannel(string mappedName, NuiSensor sensor) { _sensor = sensor; _mappedFile = MemoryMappedFile.OpenExisting(mappedName); mappedFileAccessor = _mappedFile.CreateViewAccessor(); mappedFileAccessor.SafeMemoryMappedViewHandle.AcquirePointer(ref MappedPointer); lockDatas = new int *[BlockCount]; for (int i = 0; i < BlockCount; i++) { lockDatas[i] = (int *)(sizeof(int) * i + MappedPointer); } }
/// <summary> /// Handles the nui sensor disconnected /// </summary> /// <param name="sensor">connected sensor</param> void nuiApp_OnSensorDisconnected(NuiSensor sensor) { if (useSensor == sensor) { //set usesensor to null when usesensor is disconnected useSensor = null; //use invoke for access to the this wpf window's ui Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { //init sensor's name,vendor textbox sensorNameTB.Text = ""; sensorVendorTB.Text = ""; })); } }
/// <summary> /// Handles the nui sensor connected /// </summary> /// <param name="sensor">connected sensor</param> void nuiApp_OnSensorConnected(NuiSensor sensor) { if (useSensor == null) { //set usesensor to now connected sensor when usesensor is empty useSensor = sensor; //open body frame useSensor.OpenBodyFrame(); // get size of joint space this.displayWidth = useSensor.DepthInfo.Width; this.displayHeight = useSensor.DepthInfo.Height; //use invoke for access to the this wpf window's ui Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { //update sensor's name,vendor textbox sensorNameTB.Text = useSensor.Name; sensorVendorTB.Text = useSensor.Vendor; })); } }