private GetMotorAccelerometer ( |
||
motor | ||
x | short | |
y | short | |
z | short | |
Результат | bool |
public CameraWindow(string devSerial) { InitializeComponent(); Closing += new System.ComponentModel.CancelEventHandler(OnClosing); xp.Minimum = -981; xp.Maximum = 981; yp.Minimum = -981; yp.Maximum = 981; zp.Minimum = -981; zp.Maximum = 981; try { motor = CLNUIDevice.CreateMotor(devSerial); camera = CLNUIDevice.CreateCamera(devSerial); } catch (System.Exception ex) { MessageBox.Show(ex.Message); Environment.Exit(0); } CLNUIDevice.SetMotorPosition(motor, 0); serial.Content = string.Format("Serial Number: {0}", devSerial); accelerometerTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(100), DispatcherPriority.Normal, (EventHandler) delegate(object sender, EventArgs e) { short _x = 0, _y = 0, _z = 0; CLNUIDevice.GetMotorAccelerometer(motor, ref _x, ref _y, ref _z); x.Content = _x.ToString(); xp.Value = _x; y.Content = _y.ToString(); yp.Value = _y; z.Content = _z.ToString(); zp.Value = _z; }, Dispatcher); accelerometerTimer.Start(); led.SelectionChanged += new SelectionChangedEventHandler(led_SelectionChanged); led.SelectedIndex = 0; colorImage = new NUIImage(640, 480); color.Source = colorImage.BitmapSource; depthImage = new NUIImage(640, 480); depth.Source = depthImage.BitmapSource; running = true; captureThread = new Thread(delegate() { // Trace.WriteLine(string.Format("Camera {0:X}", camera.ToInt32())); if (CLNUIDevice.StartCamera(camera)) { while (running) { CLNUIDevice.GetCameraColorFrameRGB32(camera, colorImage.ImageData, 500); CLNUIDevice.GetCameraDepthFrameRGB32(camera, depthImage.ImageData, 0); Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action) delegate() { colorImage.Invalidate(); depthImage.Invalidate(); }); } CLNUIDevice.StopCamera(camera); } }); captureThread.IsBackground = true; captureThread.Start(); }
public CameraWindow(string devSerial) { this.devSerial = devSerial; InitializeComponent(); Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing); try { motor = CLNUIDevice.CreateMotor(devSerial); camera = CLNUIDevice.CreateCamera(devSerial); labelSERIAL.Content = string.Format("Serial Number: {0}", devSerial); } catch { MessageBox.Show("Is your device connected! Drivers installed?", "Kinect Not Found!"); errquit = true; this.Close(); } DataContext = this; TheCharacter = "█"; FromLeft = 526; FromTop = 136; TheFontSize = 5; accelerometerTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(100), DispatcherPriority.Normal, (EventHandler) delegate(object sender, EventArgs e) { short _x = 0, _y = 0, _z = 0; CLNUIDevice.GetMotorAccelerometer(motor, ref _x, ref _y, ref _z); double gx = 0; double gy = 0; _x = (short)(_x - _xCal); _y = (short)(_y - _yCal); _z = (short)(_z - _zCal); if (comboXAXIS.SelectedIndex == 0) { gx = _x + 1000; } else if (comboXAXIS.SelectedIndex == 1) { gx = _y + 1000; } else if (comboXAXIS.SelectedIndex == 2) { gx = _z + 1000; } if (comboYAXIS.SelectedIndex == 0) { gy = _x + 1000; } else if (comboYAXIS.SelectedIndex == 1) { gy = _y + 1000; } else if (comboYAXIS.SelectedIndex == 2) { gy = _z + 1000; } FromLeft = 389 + (int)(gx / 9.661835748792271); FromTop = 34 + (int)(gy / 9.661835748792271); labelX.Content = "X: " + (_x).ToString(); progressX.Value = _x; labelY.Content = "Y: " + (_y).ToString(); progressY.Value = _y; labelZ.Content = "Z: " + (_z).ToString(); progressZ.Value = _z; }, Dispatcher); accelerometerTimer.Start(); comboLED.SelectionChanged += new SelectionChangedEventHandler(comboLED_SelectionChanged); comboLED.SelectedIndex = 0; comboFEED.SelectionChanged += new SelectionChangedEventHandler(comboBox1_SelectionChanged); comboFEED.SelectedIndex = 0; comboXAXIS.SelectedIndex = 0; comboYAXIS.SelectedIndex = 1; comboTheSize.SelectionChanged += new SelectionChangedEventHandler(comboBox1_SelectionChanged_1); comboTheSize.SelectedIndex = 5; sliderTILT.Maximum = 8000; sliderTILT.Minimum = -8000; sliderTILT.Value = 0; CLNUIDevice.SetMotorPosition(motor, 0); }