using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Microsoft.Kinect; namespace Wpf { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { public MainWindow() { } private void Window_Loaded(object sender, RoutedEventArgs e) { startKinect(); } private void Window_Closed(object sender, EventArgs e) { _kinect.Stop(); } KinectSensor _kinect; private void startKinect() { if (KinectSensor.KinectSensors.Count>0) { _kinect = KinectSensor.KinectSensors[0]; MessageBox.Show("Kinect 状态为:" + _kinect.Status); _kinect.ColorStream.Enable(ColorImageFormat.RawBayerResolution640x480Fps30); _kinect.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); _kinect.SkeletonStream.Enable(); _kinect.AllFramesReady +=new EventHandler<AllFramesReadyEventArgs>(_kinect_AllFramesReady); _kinect.Start(); } else { MessageBox.Show("未发现Kinect设备"); } } void _kinect_AllFramesReady(object sender, AllFramesReadyEventArgs e) { using (ColorImageFrame colorFrame=e.OpenColorImageFrame()) { if (colorFrame == null) { return; } byte[] pixels = new byte[colorFrame.PixelDataLength]; colorFrame.CopyPixelDataTo(pixels); int strid = colorFrame.Width * 4; colorImage.Source = BitmapSource.Create(colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Bgr24, null, pixels, strid); } } } }
这里不是缓存不足,而是你BitmapPalette不能为null
谢谢你的 回答 错误已找到 但不是这个
_kinect.ColorStream.Enable(ColorImageFormat.RawBayerResolution640x480Fps30);
参数错误
请问哈是为什么有这个错呢
@小严: 请问你是怎么解决的,我现在也是这个错
猜测是变量pixels或者strid的内存空间有问题
谢谢你的 回答 错误已找到 但不是这个
参数错误
错误已找到
参数错误