internal void ChangeColorResolution(KinectBase.ColorImageFormat newResolution) { kinect.ColorStream.Disable(); if (newResolution != KinectBase.ColorImageFormat.Undefined) { kinect.ColorStream.Enable(convertColorImageFormat(newResolution)); //Get the size, in bytes, of the new image array and reset the image pool int size = 0; if (newResolution == KinectBase.ColorImageFormat.InfraredResolution640x480Fps30) { size = 640 * 480 * 2; } else if (newResolution == KinectBase.ColorImageFormat.RawBayerResolution1280x960Fps12 || newResolution == KinectBase.ColorImageFormat.RgbResolution1280x960Fps12) { size = 1280 * 960 * 4; } else { size = 640 * 480 * 4; } colorImagePool.ResetPool(() => new byte[size]); isColorStreamOn = true; } else { isColorStreamOn = false; } }
private void colorResComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { KinectBase.ColorImageFormat newFormat = KinectBase.ColorImageFormat.Undefined; switch (colorResComboBox.SelectedIndex) { case (0): { newFormat = KinectBase.ColorImageFormat.RgbResolution640x480Fps30; break; } case (1): { newFormat = KinectBase.ColorImageFormat.RgbResolution1280x960Fps12; break; } case (2): { newFormat = KinectBase.ColorImageFormat.InfraredResolution640x480Fps30; break; } case (3): { newFormat = KinectBase.ColorImageFormat.Undefined; break; } } kinectSettings.colorImageMode = newFormat; kinectCore.ChangeColorResolution(newFormat); }
private ColorImageFormat convertColorImageFormat(KinectBase.ColorImageFormat format) { //The color formats are all numbered the same for the Kienct v1, so we can do a straight cast return((ColorImageFormat)format); }